| Author |
ServerSocket question
|
Raghav Mathur
Ranch Hand
Joined: Jan 12, 2001
Posts: 639
|
|
Hi all i've set the ServerSocket constructor to accept 1 connection i.e ( ServerSocket socket = new ServerSocket(5000,1); However if the server socket has already accepted a connection and another client socket tries to connect to it , it sucessfully makes a connection to the ServerScocket though the ServerSocket does not accept it (The client socket does not even throw an exception) . How can i prevent the client socket from making a connection to the serversocket if the serversocket has already accepted a connection ? Thanks in advance
|
Raghav.
|
 |
Raghav Mathur
Ranch Hand
Joined: Jan 12, 2001
Posts: 639
|
|
|
Any inputs ?
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
You're not setting the maximum # of connections accepted -- you're setting the length of the queue of clients waiting to be accepted. If the queue is full, the connection is rejected. Not sure if a queue size 0 would actually work. - Peter
|
 |
Raghav Mathur
Ranch Hand
Joined: Jan 12, 2001
Posts: 639
|
|
Originally posted by Peter den Haan: You're not setting the maximum # of connections accepted -- you're setting the length of the queue of clients waiting to be accepted. If the queue is full, the connection is rejected. Not sure if a queue size 0 would actually work. - Peter
I,am not using a while loop that means i,am allowing only one conection at one time . Secondly i've specified the que length as 1.
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
And your second client is patiently sitting in your 1-deep queue, waiting for its turn to be served. - Peter
|
 |
Raghav Mathur
Ranch Hand
Joined: Jan 12, 2001
Posts: 639
|
|
Thats the point . Why should my second client who connects to the server wait when the server is accepting just one connection and secondly it is not even accepting connections in a while loop. Should not the second client who connects to this server throw a connection refused sort of Exception.
Originally posted by Peter den Haan: And your second client is patiently sitting in your 1-deep queue, waiting for its turn to be served. - Peter
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
Did you try a 0 queue depth? As I said, I'm not sure if it's legal or not, but worth a try. - Peter
|
 |
 |
|
|
subject: ServerSocket question
|
|
|