开发者

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.

Is there a reason why telnet would be able to communicate with my server but my client program could not?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜