Byte stream send/receive problem...any help?
Hi all,
I ve got the following client (applet) & server (application) and I am trying to tranfer some data between them, but strange things happen...!
For example some times the packet comes double (e.g. "Athan;Athan;" instead of "Athan;") or other times comes half! (e.g. "Atha" instead of "Athan;") I cannot understand what is going wrong! Please have a look to my code. Here is a part of it:
Server:
i = new DataInputStream(s.getInputStream());
while(startSession) //always true
{
while (i.available()<=1){};
{
str=new StringBuffer();
byte temp[]=new byte[600]; //600 is the maximum request packet size
int len=0;
len=i.read( temp );
for (int i=0;i<len;i++)
{
str.append((char)temp);
}
System.out.println(""+str.toString()+"len:"+str.length());
Client:
out = new DataOutputStream(soc.getOutputStream());
public void send(String s)
{
for (int i=0;i<s.length();i++)
{
try{
out.write((int).charAt(i));
}
catch (IOException e){}
}
I am almost sure that the problem is on the server side, since the client is sending correctly the packet.
Thanx in advance,
Athan>

