Ping request UDP C# PocketPC
From: Ben (benoit.rheaume_at_gmail.com)
Date: 03/10/05
- Next message: Darren: "Re: CF ComboBox databinding bug?"
- Previous message: Ilya Tumanov [MS]: "Re: CF ComboBox databinding bug?"
- Next in thread: Paul G. Tobey [eMVP]: "Re: Ping request UDP C# PocketPC"
- Reply: Paul G. Tobey [eMVP]: "Re: Ping request UDP C# PocketPC"
- Reply: Rick: "Re: Ping request UDP C# PocketPC"
- Reply: Sergey Bogdanov: "Re: Ping request UDP C# PocketPC"
- Messages sorted by: [ date ] [ thread ]
Date: 10 Mar 2005 15:22:10 -0800
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: Darren: "Re: CF ComboBox databinding bug?"
- Previous message: Ilya Tumanov [MS]: "Re: CF ComboBox databinding bug?"
- Next in thread: Paul G. Tobey [eMVP]: "Re: Ping request UDP C# PocketPC"
- Reply: Paul G. Tobey [eMVP]: "Re: Ping request UDP C# PocketPC"
- Reply: Rick: "Re: Ping request UDP C# PocketPC"
- Reply: Sergey Bogdanov: "Re: Ping request UDP C# PocketPC"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|