Client and Server fail to communicate
I have a client/server program in c. While the server runs, I can send it command via telnet and it works fine. In addition, nmap reports the port to be open. Similarly, I can successfully use (connect(sock, (struct sockaddr *) &servAddr, sizeof(servAddr))
if my IP is the address of google. However, If I try and use 127.0.0开发者_JS百科.1
to connect I get a -1
response from connect()
. I'm using ports in the 13000 range.
You either have a local firewall that is preventing your client program from connecting (you may need to whitelist the client program if this is on Windows) or you're filling in the IP address you pass to connect
incorrectly. Depending on the OS you're using you should either check errno
or GetLastError()
to see what went wrong.
You'd better get details about the problem with strerror(errno)
if under linux, many reasons may lead to the disconnection.
精彩评论