amccormack
amccormack

Reputation: 13927

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.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?

Upvotes: 0

Views: 104

Answers (2)

Summer_More_More_Tea
Summer_More_More_Tea

Reputation: 13436

You'd better get details about the problem with strerror(errno) if under linux, many reasons may lead to the disconnection.

Upvotes: 1

Femi
Femi

Reputation: 64700

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.

Upvotes: 2

Related Questions