Why do I get connection refused when the server is not running?

Answer Posted / chaitanya

The connect() call will only block while it is waiting to establish a connection. When there is no server waiting at the other end, it gets notified that the connection can not be established, and gives up with the error message you see. This is a good thing, since if it were not the case clients might wait for ever for a service which just doesn't exist. Users would think that they were only waiting for the connection to be established, and then after a while give up, muttering something about crummy software under their breath.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why does the sockets buffer fill up sooner than expected?

1001


How do unix sockets work?

494


Where is the socket located?

478


What is a socket api?

535


What is difference between socket () and serversocket () class?

495






How to find other end of unix socket connection?

520


Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?

1043


Are sockets files?

513


What are the types of sockets?

498


What is the purpose of socket?

507


Why do I get EPROTO from read()?

1013


system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

1165


What is sae socket?

442


What is the difference between read() and recv()?

1598


How does unix socket work?

508