Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for pinging

Status
Not open for further replies.

pab2000

Programmer
Oct 23, 2003
1
FR
Hello,

I'm currently implementing a software in which communication between stations via sockets is used.
My problem is that before opening a socket connection I
would like to know if the station I want to establish a socket connection to can be pinged.
With the Ping command it is possible to send a timeout
and therefore to quickly know if a station is on the network.
Setting the timeout is important since I have performance
difficulties. The connect API to establish the socket connection is to long to fail when the station can not be
found on the network.
I found some source code example in the MSDN library (sending ICMP echo )but the timeout for the response does
not work. I use Microsoft Visual C++ 6 under Windows XP.
My MSDN is the January 2001 release.
Does anybody has some code for pinging in which a time out
for sending and receiving can be done ? Did it change with XP ?

 
I have had problems having the SO_RCVTIMEO option working if this is what you are referring to--I can set and read the value correctly but the blocking socket never times out. I worked around this issue by calling the select() function with a timeout before calling the blocking socket. The select() function times out properly and indicates whether or not to call recvfrom().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top