Multiple Socket Problem

Hi Friends,

I am facing a strange problem while dealing with multiple sockets. Let me give you some brief description. I have two socket connected on same IP and PORT. Let's say socket and socket. Socket will control the data flow on the socket.

Step-1=> Socket connects with server on some IP and PORT.

Step-2=> Upon Successful connection exchange some data for shakehand with server.

Step-3=> Upon successful shackhand socket2 will initiate connection with server on same IP and PORT on which socket1 is currently connected.

Step-4=> Upon successfull connection of socket2, socket1 goes in waiting state. In other words socket1 is waiting for some data.... let's say 100 bytes.

Step-5=> As socket2 is now connected I am getting continues flow of data on it(socket1). To control flow now I am sending some command on socekt1.

Step-6=> As socket1 is waiting for data, it gets responce immidiatly...... Huh and here problem occurs.

I am always receives at most 100 bytes on socket1 and it never excced this size. But I am getting more bytes lets say 200 on socket1 although I am restricting number of bytes to read in inputstream's read method.

So friends what should be problem?

Waiting for your reply....

[1294 byte] By [himanshu17a] at [2007-11-26 12:37:12]
# 1
i think you are using blocking read(byte[]) method instead use like while( (ch=read(byte))!=-1) { } if does not solves problem plz post some code @rjun
arjunamatea at 2007-7-7 16:04:24 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Thanks Arjun, But the thing is that I can't afford to make so many calls to read method. So it is not solving my problem.
himanshu17a at 2007-7-7 16:04:24 > top of Java-index,Java Mobility Forums,Java ME Technologies...