Port handling while using ServerSocket
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jaise_George
Posted On:   Wednesday, July 16, 2003 02:52 AM

Hi, Suppose I am creating a ServerSocket on port number 9000. The ServerSocket.accept() waits until a request is received and it returns a Socket instance. In the following code... ...... sServer = new ServerSocket("....", 9000); Socket sChild = null; while(true) { sChild = sServer.accept(); ProcessRequest( sChild ); } ...... my question is, if ProcessRequest() takes a long time for processing, will the ServerSocket accepts further requests from other clients?? If it blocks, what is the better way to make it available for further requests. Also I would like to know whether sChild also uses 9000 fo   More>>

Hi,


Suppose I am creating a ServerSocket on port number 9000. The ServerSocket.accept() waits until a request is received and it returns a Socket instance. In the following code...


			
......
sServer = new ServerSocket("....", 9000);
Socket sChild = null;

while(true) {
sChild = sServer.accept();
ProcessRequest( sChild );
}
......



my question is, if ProcessRequest() takes a long time for processing, will the ServerSocket accepts further requests from other clients??


If it blocks, what is the better way to make it available for further requests.


Also I would like to know whether sChild also uses 9000 for its communication, or its uses another randon Port address for the communication thereby freeing up 9000.


Thanks in advance.


Jaise George    <<Less

Re: Port handling while using ServerSocket

Posted By:   Pramod_Unawane  
Posted On:   Saturday, July 19, 2003 05:07 AM

Yes the server will handle further requests if it is not terminated. If ur code is written to handle multi threading it will work fine. If there is problem in ur ProcessRequest then all the childs will not b processed. Do chk this method and also chk that ur code handles multi threading. A child will always send request to the same port 9000 (as u have specified here).

Regards.
About | Sitemap | Contact