Ping request UDP C# PocketPC

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ben (benoit.rheaume_at_gmail.com)
Date: 03/10/05


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...



Relevant Pages

  • Re: Proxy Management Point - Service Unavailable
    ... Verify that the Task Scheduler is enabled. ... Verify that the SQL Server has named pipes enabled. ... If you are using the IIS lockdown tool on your IIS 5 servers be sure ... I've successfully turned up> a Management Point on the Central Site server. ...
    (microsoft.public.sms.admin)
  • Exchange stops fax attachments
    ... Verify that automatic routing is enabled for email and Sharepoint. ... Open the Server Management Console. ... If the administrative groups are displayed, expand Administrative Groups, ...
    (microsoft.public.windows.server.sbs)
  • Re: FAX Problem - mail system dll is invalid
    ... To manually route a fax to someone's email, ... Verify that automatic routing is enabled for email and Sharepoint. ... Open the Server Management Console. ... If the administrative groups are displayed, expand Administrative ...
    (microsoft.public.windows.server.sbs)
  • RE: Migration NT4 to W3K AD
    ... The netdom command is now working also netdom verify. ... software loaded on the NT4 server that i have uninstalled. ... verify the trust from the command line does not work like i wrote earlier. ...
    (microsoft.public.windows.server.active_directory)
  • RE: Incoming Fax error
    ... I.Verify the SMTP Virtual Server settings. ... Verify that automatic routing is enabled for email and Sharepoint. ... If the administrative groups are displayed, expand Administrative ... III.What's the version of McAfee running on the SBS server? ...
    (microsoft.public.windows.server.sbs)