I am using vc++6.0 on Win-NT4.0
I have written a service in C which is installed on IP address 220.127.116.11(this is actual IP address where the service is still running on port 9896)
Now I have written a client which is basically a systray icon lying on my machine.
The function of this client is to connect to this service after every 30 seconds and check for some file present on that system and if yes then beep and change icon.
My problem is that when you try to ping this IP address 18.104.22.168 sometimes it gives request timed out and sometimes it tell reply.........
So in my code which is as follows
struct sockaddr_in serv_addr;
if ( connect (sock , (struct sockaddr*) &serv_addr , sizeof (serv_addr) ) < 0 )
MessageBox(hwndMain,"Cannot connect to the server","ERROR",MB_ICONHAND) ;
Because of request timed out it is not able to connect to server(which is a service running) and gives me the above messagebox as "cannot connect to server"
so all furthur processing is also not possible.
I have tried this program on our LAN and it works perfect, but the problem involved is with m/c on that IP address.
Is there any way to set the time limit until which keep on trying to connect and also after connecting keep on trying to send and wait until anything is received.i.e. concept of blocking sockets in C.
If any of you wanna try to ping you can go ahead and at least ping 4-5 times to notice the actual difficulty.
Please give me source code also while give me the answer.