Socket buffer doesnt flush

From: Paul (nospam_at_nospam.com)
Date: 03/30/04


Date: Mon, 29 Mar 2004 23:15:55 -0500

I have an networking class that sends Serialized object. Problem is that
when I send the object first time it is received and it's ok. When I try to
send updated object the new data is not sent! The host receives the object
that was sent the first time whenever I try to send updated object. What
happens to updated data, i dont know. I guess it never gets past the
writeObject function. I set up the connection this way

tcpSocket=new Socket(remoteHost,remotePort);
output=new ObjectOutputStream(tcpSocket.getOutputStream());
input=new ObjectInputStream(tcpSocket.getInputStream());

and I send data this way inside the networking object

public void SendData (Object obj)
  {
    try
    {
      StatusNotify("Received: "+((ChatPacket)obj).getScore());
      output.writeObject(obj);
      output.flush();
    }
    catch (IOException e)
    {
      ErrorNotify("IOException (SendMessage): "+e.getMessage());
    }
  }

this is the function that updates and calls the network object

if(co.getStatus()!=co.CO_NOTCONNECTED)
    {
      packBuffer.setMessage(textField1.getText());
      packBuffer.SetScore(1);
      WriteLog(packBuffer.getName()+"["+packBuffer.getScore()+"]:
"+packBuffer.getMessage());
      co.SendData(packBuffer);
      textField1.setText("");
    }

This is the output i get in the Log window

Paul[2]: Hello there

Paul[2]: Hello there

Paul[2]: Hello there

"Hello there" was indeed the first message but other two were different, but
somehow the first message doesnt seem to leave the buffer even after flush.

Can anybody shine light on this disaster? This networking portion is an
important part of my project and has to be error proof.

Thanks



Relevant Pages