dcsimg
problem with Java.io.DataInputStream
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhishek_Dhama
Posted On:   Monday, November 17, 2003 06:44 AM

hi all, We have this application based on client server architecture. Client and server are more or less symmetrical.Now the problem is code works fine when we run it on same machine but when we run client and server on two different machines program raises exception. File is transferred without any problem from client to server but when client tries to read in from DataInputStream it raises an exception. Message says "connection reset". On server machine file transfer is shown to be smooth without any problems. I am attaching part of code where it raises exception. while(in.readBoolean()){ String filename = new StringBuffer(recievedfilename).append(r   More>>

hi all,
We have this application based on client server architecture.
Client and server are more or less symmetrical.Now the problem
is code works fine when we run it on same machine but when we run
client and server on two different machines program raises exception.
File is transferred without any problem from client to server but when
client tries to read in from DataInputStream it raises an exception.
Message says "connection reset". On server machine file transfer is
shown to be smooth without any problems.
I am attaching part of code where it raises exception.

			

while(in.readBoolean()){
String filename = new StringBuffer(recievedfilename).append(recievedfilecounter).append(".zip").toString();
recievedfilecounter++;
File filehandle = BufferManager.createFile(filename);
//read length of buffer from sender side
System.out.println("timeout:"+clientSocket.getSoTimeout());
int payloadLength = in.readInt();
//create a buffer that can contain the data
byte[] buf = new byte[ payloadLength ];
//read data from sender and write it to the buffer
int read = in.read( buf , 0 , payloadLength ) ;
//write data received from sender to this file:

FileOutputStream printToFile = new FileOutputStream( filehandle );
DataOutputStream dos = new DataOutputStream( printToFile );
dos.write( buf , 0 , payloadLength );
dos.close();

Input stream is constructed here:
			

COB = InetAddress.getByName( ipaddress );
clientSocket = new Socket( COB , PORT );
clientSocket.setSoTimeout(2000);
clientSocket.setKeepAlive(true);
//stream for sending data
out = new DataOutputStream( clientSocket.getOutputStream() );
//stream for receiving data
in = new DataInputStream( clientSocket.getInputStream() );
System.out.println("connection opened");


It would be wonderful if someone could point out where the problem lies.
regds
/dhama    <<Less
About | Sitemap | Contact