Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > I/O blocks in server side thread when i pull off the battery from client side

Thread Tools

I/O blocks in server side thread when i pull off the battery from client side

goyal_85 goyal_85 is offline
Junior Member
Join Date: Jun 2010
Posts: 1
hi, i m working on client socket connection. client is a GPRS hardware device. i m receiving request from this client on my serversocket and then opening multiple threads. my problem is that when device/client close the socket then my IO detects that throws an exception but when i put off the battery from the device while sending the request to the serversocket it is blocked without throwing any exception. somebody suggested me to use setSOTimeout() to comeout from the blocking thread.

i have tried Socket.setSOTimeout(int) . but this is not working out in my case. i m sending my code properly. in main class--- try {

serverSocket = new ServerSocket(port);//creating a serversokcet on a port

System.out.println("Server waiting for client on port " +


} catch (Exception e) {


handleExceptions("errorServerSocketOpen.txt", e);


try {

while (true) {
Socket clientSocket = serverSocket.accept();//accepting the client connection and creating client socket

// clientSocket.setSoTimeout(60000);// this is what i added.timeout on each //client socket opened in threads

new AcceptConnection(clientSocket);//calling the constructor of other //class to open a new thread

System.out.println("constructor called.....");

} catch (Exception e) {

handleExceptions("errorClientSocketOpen.txt", e);


in other class--- public class AcceptConnection implements Runnable {

public AcceptConnection(Socket socket) {

this.clientSocket = socket;

if (clientSocket != null) {

new Thread(this).start();


public void run() {

InputStream inputStream = clientSocket.getInputStream();

DataOutputStream dataOutputStream = new DataOutputStream(clientSocket.getOutputStream());

byte[] mainBuffer = new byte[2048];

int len = -1, totalLength = 0;

debugInfo = " GOING TO READ FROM SOCKET.... " + "\n";

while ((len = > -1) {
totalLength = len;
}//end of while

} }//end of other class

now my problem is that when multiple threads are opened and i send the data from client than after 60 seconds it closes the main socket and stops receiving the data.and a readtimeout error occurs.

please help me out and tell me how my objective could be fulfilled.

thanks in advance
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
weak pull up and pull down VHDL 2 06-28-2006 02:18 PM
How-to? - Process Client-side AND Server-side Code Blocks With aspnet Button Joey ASP .Net 1 01-03-2006 11:01 PM
client-side browser timeout OR server-side web server timeout?? (please help) Java 0 01-04-2005 04:06 AM
procs/blocks - blocks with procs, blocks with blocks? matt Ruby 1 08-06-2004 01:33 AM