TWSocket
1 answers - 1303 bytes -

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: T);
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 SessionConnected I send a SendStr command to get some
data. I read this with the DataAvailable:
procedure TForm1.icsWSocketDataAvailable(Sender: T; 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