I wrote a windows service for watch repeater_service viewer port and server port state. Because sometimes my repeater stop working. When repeater service port is no responding, my windows service will restart repeater_service automatic.
my windows service code for connect to repeater service
try
client.sin_family := AF_INET; //Set the protocol to use , in this case (IPv4)
client.sin_port := htons(dwPort); //convert to TCP/IP network byte order (big-endian)
client.sin_addr.s_addr := inet_addr(PAnsiChar(AnsiString(ipAddressStr))); //convert to IN_ADDR structure
sock :=socket(AF_INET, SOCK_STREAM, 0); //creates a socket
SetSocketTimeOut(sock,10000,10000) ;
Result:=connect(sock,client,SizeOf(client))=0; //establishes a connection to a specified socket, if result false, i will restart repeater
finally
WSACleanup;
end;
today, i got some strange situation. when ipAddressStr (above code) is 127.0.0.1 everything is fine. but when I run the windows service from the other computer. ipAddressStr is IP address of repeater server. When my windows service connect to repeater_service. THE REPEATER SERVICE STOP RESPONDING FOR WINVNC or VNCVIEWER'S REQUEST.
so i guess, some people use tools scan ip and port over internet. when some people scan my repeater service. my repater service will hang.
thanks and sorry about my poor English .....