Hi,

I am writing a little program wchich is polling another program using
TWSocketServer. For testing purposes I press a button which connects to
the other program:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if icsWSocket.State  <> wsClosed then
    icsWSocket.Close;

  if icsWSocket.State = wsClosed then begin
    icsWSocket.Addr := address.Text;
    icsWSocket.Port := port.Text;
    icsWSocket.Connect;
    Timer1.Enabled := false;
  end;
end;

In the event OnSessionConnected I send a SendStr command to get some
data. I read this with the OnDataAvailable:

procedure TForm1.icsWSocketDataAvailable(Sender: TObject; ErrCode: Word);
var inbuf : string;
begin
  inbuf := icsWSocket.ReceiveStr;

  if pos('Status', inbuf) > 0 then
  begin
    inbuf := StrAfter(#$FF, inbuf);
    decode_data(inbuf);
    icsWSocket.close;
  end;
end;

If I got the right data I want to close the connection. It is closed
then. If I press a second time the button the Connection is closed
without recieving any data and gives an error code 100053 (Connection
Aborted). Why dows this event occur ?? Normally a timer should connect
automatically every 20 seconds and get the status of the other software.

Thanks
  Stefan

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to