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

What's the difference between a socket and a port?

458


How do unix sockets work?

492


What is the purpose of socket?

503


Are sockets files?

505


Why do we need socket programming?

497






What is sae socket?

440


Why does it take so long to detect that the peer died?

1150


What are the types of sockets?

494


What are the pros/cons of select(), non-blocking I/O and SIGIO?

978


Can a socket have multiple ports?

506


Can multiple sockets use the same port?

494


How can I write a multi-homed server?

1275


How can I force a socket to send the data in its buffer?

1097


Why do I get EPROTO from read()?

1011


What is a socket file?

512