In case of a Serversocket have full of request in its backlog and doing a long running job what will be the socket behaviour. When I try this, from windows telnet is ok, it connects. But from unix it gets "connection refused". My application is written in java and running on IBM jvm. By the way I came to that point where our application was not responding telnet from unix. Not respoing means it was writing "tyring..." and hangs, not refusing or connecting. Can anybody justify this behavior? Thank you.
Asked
Active
Viewed 2,008 times
1 Answers
2
You should not get "Connection refused", if the socket is in LISTEN state. Until you exhaust the slots provided by the backlog setting, your connect requests should be acknowledged (but nothing more happens). When you reach the backlog limit set by the listen
system call, "Trying..." is the normal behaviour (the server is dropping packets until a listening backlog slot is available, the client is retransmitting SYN packets until the connect timeout happens or the server acknowledges the connect request).

Laszlo Valko
- 2,683
- 25
- 29
-
Firstly thank you for answer. When I try this, socket is not on accept(its on breakpoint below accept for instance) (backlog reached the limit) I took Connection refused. when I look at with netstat I see my port in listening mode.I could never generate "trying.." case on my machine which I saw in case of problem in production before. – cacert Dec 03 '13 at 15:48
-
2It does not need to "be on accept". To start receiving connections, only `bind` & `listen` are needed. Then, every incoming connection gets accepted by the OS, and queued up as long as the backlog parameter allows. When the application reaches `accept`, it'll get those already accepted connections from the queue, one at a time. – Laszlo Valko Dec 03 '13 at 16:54
-
1This behaviour is platform-dependent. Windows issues an RST when the backlog fills up, which results in 'connection refused'. Unix, Linux just drop the SYN packet. – user207421 Dec 04 '13 at 01:24