Re: Ping request UDP C# PocketPC
From: Paul G. Tobey [eMVP] (ptobey)
Date: 03/10/05
- Next message: Ilya Tumanov [MS]: "Re: CF ComboBox databinding bug?"
- Previous message: fig000: "Reading a file in RAPI"
- In reply to: Ben: "Ping request UDP C# PocketPC"
- Next in thread: Rick: "Re: Ping request UDP C# PocketPC"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Mar 2005 16:35:50 -0700
I think that send time-out is not settable on Windows CE, hence the error.
I'm not sure what a UDP send time-out would mean anyway, though.
I'd go back to the UdpClient-based code and figure out why Connect() is not
returning. There's no such thing as a 'connected' UDP socket. It's a
datagram protocol. There's no state in the connection. Connect(), as far
as I can tell, should return immediately having done nothing but save the
port number and IPAddress that you passed to it.
Your 'ping' code wouldn't do anything, even if the send time-out meant
something. There's no response from the other end of a UDP datagram send
mandated. Unless your *code* running on the other end responds, as PING's
peer program does, you won't ever get anything back.
Paul T.
"Ben" <benoit.rheaume@gmail.com> wrote in message
news:de368bad.0503101522.244b17c7@posting.google.com...
> Hello,
>
> I'm writing an application which communicate by UDP protocol from a
> PocketPC to a computer. I have to verify if the server (computer) is
> still available, or when I'm trying to connect (UdpClient.Connect),
> the application freezes. Since I can't catch any exception with the
> Connect function, I would like to create a "ping request", using the
> Socket class, which verify every x seconds if the server is available.
>
> Here is a bit of my code :
>
>
> IPEndPoint endPoint = new
> IPEndPoint(IPAddress.Parse("10.102.100.127"), 9000);
> EndPoint PingEndPoint = (EndPoint)endPoint;
> byte[] msg = new byte[1] {1};
>
> ping = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
> ProtocolType.Udp);
>
> try
> {
> ping.SetSocketOption(SocketOptionLevel.Udp,
> SocketOptionName.SendTimeout, 2000);
> }
> catch (SocketException se)
> {
> MessageBox.Show(se.ToString() + " " + se.ErrorCode);
> }
>
> try
> {
> ping.SendTo(msg, PingEndPoint);
> }
> catch (Exception so)
> {
> // Here it would tell me that the server is offline
> MessageBox.Show(so.ToString());
> }
>
> I'm having a SocketException in the first try-catch block :
>
> An invalid argument was supplied 10022
>
> Does anyone can tell me how to proceed correctly?
> Thanks in advance...
- Next message: Ilya Tumanov [MS]: "Re: CF ComboBox databinding bug?"
- Previous message: fig000: "Reading a file in RAPI"
- In reply to: Ben: "Ping request UDP C# PocketPC"
- Next in thread: Rick: "Re: Ping request UDP C# PocketPC"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|