Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SocketTimeoutException: Read timed out

Status
Not open for further replies.

shekinskiy

Programmer
Nov 14, 2005
11
TR
hi

i have a server socket and more that 200 client socket,
i get exception above in client socket and my codes is bellow.

Code:
//open method
ServerSocket listener=new ServerSocket(port,Integer.MAX_VALUE);

....
//accept method in loop in thread
listener.setSoTimeout( 100000000L );
Socket acceptedSocket = listener.accept();

....
//receive method in loop in new thread for each conn.
inputStream = new BufferedInputStream( acceptedSocket.getInputStream(), 2048 );
outputStream = new BufferedOutputStream( acceptedSocket.getOutputStream(), 2048 );
long longSoTimeoutForClientSocket = 10000L;
long longSoTimeoutForAcceptedSocket = 7200000L;
acceptedSocket.setSoTimeout( longSoTimeout );
inputStream.read( byte[4096], 0, 4096 OR inputStream.available() );

....
//send method
acceptedSocket.setSoTimeout( 1000L );
outputStream.write( data.getBuffer(), 0, data.length() );
outputStream.flush();

recieve and send method is same in both socket; client and accepted socket, except SoTimeout.


thanks for any help,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top