Why do I get connection refused when the server is not running?
Answer / 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 |
Can a single socket port be used for multiple applications?
How can I force a socket to send the data in its buffer?
What is the difference between SO_REUSEADDR and SO_REUSEPORT?
How do I send [this] over a socket?
Where is the socket located?
What is a socket set used for?
How come only the first part of my datagram is getting through?
What are raw sockets?
How can I read ICMP errors from connected UDP sockets?
Can multiple sockets use the same port?
What exactly does SO_REUSEADDR do?
What is a sae socket?