Re: [twsocket] disconnect problem with tcp socket

2011-02-10 Thread Francois PIETTE
am building a chat system and when a user is disconnected from there host 
there id is stuck
within the socket so am wondering is there anyway of removing dead IDs 
once

connection is lost to server?


In my opinion, the best way to handle this is to implement at the 
application layer a kind of ping.
Your chat system surely use a kind of messaging between client and server. 
Just implement one more command from server to client: every minute your 
server send a "noop" command to the client which simply answers "OK". If the 
client do'nt answer, then assume his connection is lost and cleanup your 
system.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

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


[twsocket] disconnect problem with tcp socket

2011-02-10 Thread Simon
Hello,
am building a chat system and when a user is disconnected from there host there 
id is stuck within the socket so am wondering is there anyway of removing dead 
IDs once connection is lost to server?

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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Wilfried Mestdagh
Hello Ronaldo,

10053 is when OS decide to stop the connection. Normally this is because
of some network problem, a malfunctioning router or switch. But many
virus scanners and firewalls are doing wierd things with TCP, so stop
any service of it (not disable it) and test again.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Friday, May 1, 2009, 18:07, Ronaldo DeVinche wrote:

> exceptions are without errors
> well i checked all events on TWserverSocket and TWsocket and errors ocurs
> only here:

> *procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
> **  begin   {this  is Socket = TWSocket}
>  memo1.lines.add( Format('Error %d on SocketSessionClosed', [ErrCode])

> code is *error 10053
> *seems **somthing**  is wrong in proxy (my code)  its skip some packets
> after proxy (socket (TWsocket)) is dissconneted
> socket closed

> i should look closer to my code and meybe even rebuild it

> Thank you!

> Ronalds




> *

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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Ronaldo DeVinche
exceptions are without errors
well i checked all events on TWserverSocket and TWsocket and errors ocurs
only here:

*procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
**  begin   {this  is Socket = TWSocket}
 memo1.lines.add( Format('Error %d on SocketSessionClosed', [ErrCode])

code is *error 10053
*seems **somthing**  is wrong in proxy (my code)  its skip some packets
after proxy (socket (TWsocket)) is dissconneted
socket closed

i should look closer to my code and meybe even rebuild it

Thank you!

Ronalds




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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Wilfried Mestdagh
Hello Ronaldo,

oke we are getting somewhere :)

> procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
> begin   {this  is Socket = TWSocket}
> memo1.lines.add('Proxy Disconnected from Server!');
> memo1.lines.add( Format('Error %d on SocketSessionClosed', [GetLastError])

You dont' need to call the last error from windows. you have an ErrCode
argument. So pleas change this to:

 memo1.lines.add( Format('Error %d on SocketSessionClosed', [ErrCode])

also in al the other events is an ErrCode argument, so log this
everyware during development.

> only here i got error : "Error 5 on SocketSessionClosed"

As Arno already say: Sounds like the Windows system error code
"ERROR_ACCESS_DENIED" but this is probably somewhere in your code and
possible also the reason for a winsock failure.

> its closes on Socket.Receive
> in packet log i see: Proxy Read from server -1 bytes <--this is
> socket.Receive (TWsocket)

Put a try / except block in the Receeive event. Possible you have an
exception over there and the reason for the close.

Also for the moment do the same in all events an also in all events log
the ErrorCode argument as in my example.

> sory for my poor English.

No probelm at all :)

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Friday, May 1, 2009, 16:20, Ronaldo DeVinche wrote:

> *I don't see anywere in your code logging of the ErrCode argument in the
> TWSocket events! So it is not sure where you get the error 5*

> procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
> begin   {this  is Socket = TWSocket}
> memo1.lines.add('Proxy Disconnected from Server!');
> memo1.lines.add( Format('Error %d on SocketSessionClosed', [GetLastError])
> );
> ClientConnected:= False;
> end;

> only here i got error : "Error 5 on SocketSessionClosed"
> Only this socket closes.

> LocalClient (TWSocketClient) is still connected to server (TWServerSocket)

> *
> I see you have a procedure ServerDataAvailable. Is this handler assigned
> to the OnDataAvailable of TWSocketServer? If so this is wrong. The
> serversocket will not receive data.

> LocalClient is assigned in Server.OnClientConnect. That is good if you
> use only 1 connection simultanously but if a second connection is
> etablished you loose the original reference to it.*

> well.. i still only lierning delphi
> and this was only way that i can figure out to get all this work

> dont have an idea how to do this in other way..

> *I already asked this, but again: witch socket does the close? And as
> additional question, when does it close (when sending, receiving etc)?*

> Closes only Socket (TWsocket)
> LocalClient Socket (TWSocketClient) is still connected to Server
> (TWsocketServer)

> its closes on Socket.Receive
> in packet log i see: Proxy Read from server -1 bytes <--this is
> socket.Receive (TWsocket)
> in error log i see: Error 5 on SocketSessionClosed  <-this is socket
> (TWsocket)

> PS.
> sory for my poor English.

> PSS.
> Thanks for your time

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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Ronaldo DeVinche
*I don't see anywere in your code logging of the ErrCode argument in the
TWSocket events! So it is not sure where you get the error 5*

procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
begin   {this  is Socket = TWSocket}
memo1.lines.add('Proxy Disconnected from Server!');
memo1.lines.add( Format('Error %d on SocketSessionClosed', [GetLastError])
);
ClientConnected:= False;
end;

only here i got error : "Error 5 on SocketSessionClosed"
Only this socket closes.

LocalClient (TWSocketClient) is still connected to server (TWServerSocket)

*
I see you have a procedure ServerDataAvailable. Is this handler assigned
to the OnDataAvailable of TWSocketServer? If so this is wrong. The
serversocket will not receive data.

LocalClient is assigned in Server.OnClientConnect. That is good if you
use only 1 connection simultanously but if a second connection is
etablished you loose the original reference to it.*

well.. i still only lierning delphi
and this was only way that i can figure out to get all this work

dont have an idea how to do this in other way..

*I already asked this, but again: witch socket does the close? And as
additional question, when does it close (when sending, receiving etc)?*

Closes only Socket (TWsocket)
LocalClient Socket (TWSocketClient) is still connected to Server
(TWsocketServer)

its closes on Socket.Receive
in packet log i see: Proxy Read from server -1 bytes <--this is
socket.Receive (TWsocket)
in error log i see: Error 5 on SocketSessionClosed  <-this is socket
(TWsocket)

PS.
sory for my poor English.

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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Wilfried Mestdagh
Hello Ronaldo,

> yes, error is on TWsocket!
> here is code

I don't see anywere in your code logging of the ErrCode argument in the
TWSocket events! So it is not sure where you get the error 5

I also see you use OnError event of TWSocketServer and use GetLastError
there. Don't use OnError, instead use your own exception blocks at the
places where you eventually expect an exception error.

I see you have a procedure ServerDataAvailable. Is this handler assigned
to the OnDataAvailable of TWSocketServer? If so this is wrong. The
serversocket will not receive data.

LocalClient is assigned in Server.OnClientConnect. That is good if you
use only 1 connection simultanously but if a second connection is
etablished you loose the original reference to it.

I already asked this, but again: witch socket does the close? And as
additional question, when does it close (when sending, receiving etc)?

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz


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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Ronaldo DeVinche
here is code
##

type
TForm3 = class(TForm)
Socket: TWSocket;
Server: TWSocketServer;
Button1: TButton;
CheckBox1: TCheckBox;
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Memo2: TMemo;
Memo3: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ServerClientConnect(Sender: TObject; Client: TWSocketClient;
Error: Word);
procedure ServerClientDisconnect(Sender: TObject; Client: TWSocketClient;
Error: Word);
procedure ServerDataAvailable(Sender: TObject; ErrCode: Word);
procedure ServerError(Sender: TObject);
procedure SocketDataAvailable(Sender: TObject; ErrCode: Word);
procedure SocketSessionClosed(Sender: TObject; ErrCode: Word);
procedure SocketSessionConnected(Sender: TObject; ErrCode: Word);
procedure SocketSocksError(Sender: TObject; Error: Integer; Msg: string);
procedure Button2Click(Sender: TObject);

private
ClientConnected: Boolean;
ServerConnected: Boolean;
TestLoop:Boolean;
TestLoop2:Boolean;
TestLoop3:Boolean;
TestLoop4:Boolean;
{ Private declarations }
public
LocalClient: TWSocketClient;
recvbuf, sendbuf: TWSocketData;
{ Public declarations }
end;

var
Form3: TForm3;
implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
if Button1.Caption = 'Stop Proxy' then
begin
Server.Close;
Socket.Close;
Button1.Caption:='Start Proxy';
end
else
if Button1.Caption = 'Start Proxy' then
begin
server.Addr:=Edit1.Text;
server.port:=Edit2.Text;
server.Listen;
socket.addr:=Edit3.Text;
socket.port:=Edit4.Text;
Button1.Caption:='Stop Proxy';
End;
End;


procedure TForm3.FormCreate(Sender: TObject);
begin
recvbuf:= AllocMem($);
sendbuf:= AllocMem($);

ClientConnected:= False;
end;

procedure TForm3.FormDestroy(Sender: TObject);
begin
FreeMem(recvbuf, $);
FreeMem(sendbuf, $);
socket.close;
server.close;
end;

procedure TForm3.ServerClientConnect(Sender: TObject; Client:
TWSocketClient;
Error: Word);
begin
LocalClient:= Client;
LocalClient.OnDataAvailable:= Server.onDataAvailable;
if checkbox1.checked then
Socket.Connect;
memo1.lines.add('Client connected!');
ServerConnected:= True;
end;

procedure TForm3.ServerClientDisconnect(Sender: TObject; Client:
TWSocketClient;
Error: Word);
begin
memo1.lines.add('Client disconnected!');
ServerConnected:= False;

if ClientConnected then
socket.close;
end;

procedure TForm3.ServerDataAvailable(Sender: TObject; ErrCode: Word);
var
Len: Integer;
begin

Len:= LocalClient.Receive(sendbuf, $);
memo2.lines.add( Format('Read from client %d bytes', [Len]) );

if ClientConnected and (len>0) then
Socket.send(sendbuf, Len);

end;

procedure TForm3.ServerError(Sender: TObject);
begin
memo1.lines.add( Format('Error %d on server socket', [GetLastError]) );
end;


procedure TForm3.SocketDataAvailable(Sender: TObject; ErrCode: Word);
var
Len: Integer;
begin
Socket.FlushTimeout:=0;
Len:= Socket.Receive(recvbuf, $);

memo3.lines.add( Format('Proxy Read from server %d bytes', [Len]) );

if (len>0) then
LocalClient.send(recvbuf, Len);

end;

procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
begin
memo1.lines.add('Proxy Disconnected from Server!');
ClientConnected:= False;
end;

procedure TForm3.SocketSessionConnected(Sender: TObject; ErrCode: Word);
begin
ClientConnected:= True;
memo1.lines.add('Proxy connected to Server');
end;

procedure TForm3.SocketSocksError(Sender: TObject; Error: Integer; Msg:
string);
begin
memo1.lines.add('');
end;
 end.
##
>
>
>
>
>
>
>
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Ronaldo DeVinche
yes, error is on TWsocket!
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Wilfried Mestdagh
Hello Ronaldo,

As Arno already sayed this is not a winsock error. But to be sure
(because I don't see it in your code example), we are talking about the
ErrCode argument in the TWSocket events, right?

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Friday, May 1, 2009, 12:18, Ronaldo DeVinche wrote:

> i log all errors and only error i have is on SocketSessionClosed:
> *Error 5 on SocketSessionClosed*

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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Arno Garrels
Ronaldo DeVinche wrote:
> i log all errors and only error i have is on SocketSessionClosed:
> *Error 5 on SocketSessionClosed*

Sounds like the Windows system error code "ERROR_ACCESS_DENIED".

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


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Ronaldo DeVinche
i log all errors and only error i have is on SocketSessionClosed:
*Error 5 on SocketSessionClosed*
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWsocket disconnect in 60 seconds

2009-05-01 Thread Wilfried Mestdagh
Hello Ronaldo,

At first sight I see nothing wrong with your code. However it is not
normal that some of the sockets close without reason. Wich of the
sockets do the close? Maybe the close is with a winsock error, then it
will tell you more about the reason. You have at least log all the
winsock errors in the different events.

Eventually you can also take a look at HpHttpProxy and SocketSpy, both
available at user made page of overbyte.be wich does more or less the
same as your application.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Thursday, April 30, 2009, 21:40, Ronaldo DeVinche wrote:

> Hello!
> i have made a proxy (sniffer) based on TWsockets from www.overbyte.be
> all works perfect... i capture packet and if need before send it back i
> modify it
> the problem is that proxy disconnect in +/- 1 minute

> is there is way how to increase or even disable thous disconnect timup`s or
> whatever it calls

> here is code
> ##

> type
> TForm3 = class(TForm)
> Socket: TWSocket;
> Server: TWSocketServer;
> Button1: TButton;
> CheckBox1: TCheckBox;
> Memo1: TMemo;
> Edit1: TEdit;
> Edit2: TEdit;
> Edit3: TEdit;
> Edit4: TEdit;
> Label1: TLabel;
> Label2: TLabel;
> Memo2: TMemo;
> Memo3: TMemo;
> Button2: TButton;
> procedure Button1Click(Sender: TObject);
> procedure FormCreate(Sender: TObject);
> procedure FormDestroy(Sender: TObject);
> procedure ServerClientConnect(Sender: TObject; Client: TWSocketClient;
> Error: Word);
> procedure ServerClientDisconnect(Sender: TObject; Client: TWSocketClient;
> Error: Word);
> procedure ServerDataAvailable(Sender: TObject; ErrCode: Word);
> procedure ServerError(Sender: TObject);
> procedure SocketDataAvailable(Sender: TObject; ErrCode: Word);
> procedure SocketSessionClosed(Sender: TObject; ErrCode: Word);
> procedure SocketSessionConnected(Sender: TObject; ErrCode: Word);
> procedure SocketSocksError(Sender: TObject; Error: Integer; Msg: string);
> procedure Button2Click(Sender: TObject);

> private
> ClientConnected: Boolean;
> ServerConnected: Boolean;
> TestLoop:Boolean;
> TestLoop2:Boolean;
> TestLoop3:Boolean;
> TestLoop4:Boolean;
> { Private declarations }
> public
> LocalClient: TWSocketClient;
> recvbuf, sendbuf: TWSocketData;
> { Public declarations }
> end;

> var
> Form3: TForm3;
> implementation

> {$R *.dfm}

> procedure TForm3.Button1Click(Sender: TObject);
> begin
> if Button1.Caption = 'Stop Proxy' then
> begin
> Server.Close;
> Socket.Close;
> Button1.Caption:='Start Proxy';
> end
> else
> if Button1.Caption = 'Start Proxy' then
> begin
> server.Addr:=Edit1.Text;
> server.port:=Edit2.Text;
> server.Listen;
> socket.addr:=Edit3.Text;
> socket.port:=Edit4.Text;
> Button1.Caption:='Stop Proxy';
> End;
> End;


> procedure TForm3.FormCreate(Sender: TObject);
> begin
> recvbuf:= AllocMem($);
> sendbuf:= AllocMem($);

> ClientConnected:= False;
> end;

> procedure TForm3.FormDestroy(Sender: TObject);
> begin
> FreeMem(recvbuf, $);
> FreeMem(sendbuf, $);
> socket.close;
> server.close;
> end;

> procedure TForm3.ServerClientConnect(Sender: TObject; Client:
> TWSocketClient;
> Error: Word);
> begin
> LocalClient:= Client;
> LocalClient.OnDataAvailable:= Server.onDataAvailable;
> if checkbox1.checked then
> Socket.Connect;
> memo1.lines.add('Client connected!');
> ServerConnected:= True;
> end;

> procedure TForm3.ServerClientDisconnect(Sender: TObject; Client:
> TWSocketClient;
> Error: Word);
> begin
> memo1.lines.add('Client disconnected!');
> ServerConnected:= False;

> if ClientConnected then
> socket.close;
> end;

> procedure TForm3.ServerDataAvailable(Sender: TObject; ErrCode: Word);
> var
> Len: Integer;
> begin

> Len:= LocalClient.Receive(sendbuf, $);
> memo2.lines.add( Format('Read from client %d bytes', [Len]) );

> if ClientConnected and (len>0) then
> Socket.send(sendbuf, Len);

> end;

> procedure TForm3.ServerError(Sender: TObject);
> begin
> memo1.lines.add( Format('Error %d on server socket', [GetLastError]) );
> end;


> procedure TForm3.SocketDataAvailable(Sender: TObject; ErrCode: Word);
> var
> Len: Integer;
> begin
> Socket.FlushTimeout:=0;
> Len:= Socket.Receive(recvbuf, $);

> memo3.lines.add( Format('Proxy Read from server %d bytes', [Len]) );

if (len>>0) then
> LocalClient.send(recvbuf, Len);

> end;

> procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
> begin
> memo1.lines.add('Proxy Disconnected from Server!');
> ClientConnected:= False;
> end;

> procedure TForm3.SocketSessionConnected(Sender: TObject; ErrCode: Word);
> begin
> ClientConnected:= True;
> memo1.lines.add('Proxy connected to Server');
> end;

> procedure TForm3.SocketSocksError(Sender: TObject; Error: Integer; Msg:
> string);
> begin
> memo1.lines.add('');
> end;
>  end.
> ##


> Thank you!


> Ronaldo

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/

[twsocket] TWsocket disconnect in 60 seconds

2009-04-30 Thread Ronaldo DeVinche
Hello!
i have made a proxy (sniffer) based on TWsockets from www.overbyte.be
all works perfect... i capture packet and if need before send it back i
modify it
the problem is that proxy disconnect in +/- 1 minute

is there is way how to increase or even disable thous disconnect timup`s or
whatever it calls

here is code
##

type
TForm3 = class(TForm)
Socket: TWSocket;
Server: TWSocketServer;
Button1: TButton;
CheckBox1: TCheckBox;
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Memo2: TMemo;
Memo3: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ServerClientConnect(Sender: TObject; Client: TWSocketClient;
Error: Word);
procedure ServerClientDisconnect(Sender: TObject; Client: TWSocketClient;
Error: Word);
procedure ServerDataAvailable(Sender: TObject; ErrCode: Word);
procedure ServerError(Sender: TObject);
procedure SocketDataAvailable(Sender: TObject; ErrCode: Word);
procedure SocketSessionClosed(Sender: TObject; ErrCode: Word);
procedure SocketSessionConnected(Sender: TObject; ErrCode: Word);
procedure SocketSocksError(Sender: TObject; Error: Integer; Msg: string);
procedure Button2Click(Sender: TObject);

private
ClientConnected: Boolean;
ServerConnected: Boolean;
TestLoop:Boolean;
TestLoop2:Boolean;
TestLoop3:Boolean;
TestLoop4:Boolean;
{ Private declarations }
public
LocalClient: TWSocketClient;
recvbuf, sendbuf: TWSocketData;
{ Public declarations }
end;

var
Form3: TForm3;
implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
if Button1.Caption = 'Stop Proxy' then
begin
Server.Close;
Socket.Close;
Button1.Caption:='Start Proxy';
end
else
if Button1.Caption = 'Start Proxy' then
begin
server.Addr:=Edit1.Text;
server.port:=Edit2.Text;
server.Listen;
socket.addr:=Edit3.Text;
socket.port:=Edit4.Text;
Button1.Caption:='Stop Proxy';
End;
End;


procedure TForm3.FormCreate(Sender: TObject);
begin
recvbuf:= AllocMem($);
sendbuf:= AllocMem($);

ClientConnected:= False;
end;

procedure TForm3.FormDestroy(Sender: TObject);
begin
FreeMem(recvbuf, $);
FreeMem(sendbuf, $);
socket.close;
server.close;
end;

procedure TForm3.ServerClientConnect(Sender: TObject; Client:
TWSocketClient;
Error: Word);
begin
LocalClient:= Client;
LocalClient.OnDataAvailable:= Server.onDataAvailable;
if checkbox1.checked then
Socket.Connect;
memo1.lines.add('Client connected!');
ServerConnected:= True;
end;

procedure TForm3.ServerClientDisconnect(Sender: TObject; Client:
TWSocketClient;
Error: Word);
begin
memo1.lines.add('Client disconnected!');
ServerConnected:= False;

if ClientConnected then
socket.close;
end;

procedure TForm3.ServerDataAvailable(Sender: TObject; ErrCode: Word);
var
Len: Integer;
begin

Len:= LocalClient.Receive(sendbuf, $);
memo2.lines.add( Format('Read from client %d bytes', [Len]) );

if ClientConnected and (len>0) then
Socket.send(sendbuf, Len);

end;

procedure TForm3.ServerError(Sender: TObject);
begin
memo1.lines.add( Format('Error %d on server socket', [GetLastError]) );
end;


procedure TForm3.SocketDataAvailable(Sender: TObject; ErrCode: Word);
var
Len: Integer;
begin
Socket.FlushTimeout:=0;
Len:= Socket.Receive(recvbuf, $);

memo3.lines.add( Format('Proxy Read from server %d bytes', [Len]) );

if (len>0) then
LocalClient.send(recvbuf, Len);

end;

procedure TForm3.SocketSessionClosed(Sender: TObject; ErrCode: Word);
begin
memo1.lines.add('Proxy Disconnected from Server!');
ClientConnected:= False;
end;

procedure TForm3.SocketSessionConnected(Sender: TObject; ErrCode: Word);
begin
ClientConnected:= True;
memo1.lines.add('Proxy connected to Server');
end;

procedure TForm3.SocketSocksError(Sender: TObject; Error: Integer; Msg:
string);
begin
memo1.lines.add('');
end;
 end.
##


Thank you!


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


Re: [twsocket] Disconnect detection

2006-08-17 Thread Wilfried Mestdagh
Hello Frédéric,

If you start a new subject pleasd do Not reply to an existing subject
but start a new one. It is really not mutch work.

> What's the best way to detect a broken connection.

When connection will break then OnSessionClosed will fire. There you
start a timer and after some seconds or more you try to connect again.
If the host is stil not alive OnSessionConnected will fire with a
winsock error, then OnSessionClosed without winsock error and you start
over again.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Wednesday, August 16, 2006, 21:22, Frédéric SCHENCKEL wrote:

 
> Hello,


> I have a TWSocket who connects to a printer.

> What's the best way to detect a broken connection.

> TWSocket is only waiting for data from the printer (special
> printer...) therefore I do a TWSocket.connect.

> When the printer is Offline (power off for example) after the
> connection is establisched, I cannot detect that the connection is
> broken.

> What's the best way to detect this ?

> Note : the kind of socket component doesn't really mather at this
> time. Just for info, linemode is on...

> Thanks

> Best regards





> Frédéric SCHENCKEL
 
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> cab technologies
> za Nord du val de Moder
> 67350 Niedermodern
> Tél: + 33 3 88 72 25 01 / Fax: +33 3 88 72 25 02
> Notre site en Français: www.cab-technologies.fr
> Adresse support: [EMAIL PROTECTED]
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

-- 
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


Re: [twsocket] Disconnect detection

2006-08-16 Thread Francois Piette
Keep alive socket option is sometimes a solution. Frequently not.
You can send data to your device just to periodically check if it is still
alive.

Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be

- Original Message - 
From: "Frédéric SCHENCKEL" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Wednesday, August 16, 2006 9:22 PM
Subject: [twsocket] Disconnect detection


>
> Hello,
>
>
> I have a TWSocket who connects to a printer.
>
> What's the best way to detect a broken connection.
>
> TWSocket is only waiting for data from the printer (special printer...)
therefore I do a TWSocket.connect.
>
> When the printer is Offline (power off for example) after the connection
is establisched, I cannot detect that the connection is broken.
>
> What's the best way to detect this ?
>
> Note : the kind of socket component doesn't really mather at this time.
Just for info, linemode is on...
>
> Thanks
>
> Best regards
>
>
>
>
>
> Frédéric SCHENCKEL
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> cab technologies
> za Nord du val de Moder
> 67350 Niedermodern
> Tél: + 33 3 88 72 25 01 / Fax: +33 3 88 72 25 02
> Notre site en Français: www.cab-technologies.fr
> Adresse support: [EMAIL PROTECTED]
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> -- 
> 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

-- 
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


[twsocket] Disconnect detection

2006-08-16 Thread Frédéric SCHENCKEL
 
Hello,


I have a TWSocket who connects to a printer.

What's the best way to detect a broken connection.

TWSocket is only waiting for data from the printer (special printer...) 
therefore I do a TWSocket.connect.

When the printer is Offline (power off for example) after the connection is 
establisched, I cannot detect that the connection is broken.

What's the best way to detect this ?

Note : the kind of socket component doesn't really mather at this time. Just 
for info, linemode is on...

Thanks

Best regards





Frédéric SCHENCKEL
 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cab technologies
za Nord du val de Moder
67350 Niedermodern
Tél: + 33 3 88 72 25 01 / Fax: +33 3 88 72 25 02
Notre site en Français: www.cab-technologies.fr
Adresse support: [EMAIL PROTECTED]
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- 
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


Re: [twsocket] Disconnect

2006-05-05 Thread Werner
I had something simular.
Let the Client or Server close connection.
Maybe try not to close client connection, and let server close the
connection when done.

- Oorspronkelijk bericht - 
Van: "Abdullah AlQasim" <[EMAIL PROTECTED]>
Aan: 
Verzonden: donderdag, mei 04, 2006 14:46
Onderwerp: [twsocket] Disconnect


> Hello All,
>
> I am newbie with TWSocket  I have some critical problem with my
> project :
>
> My client disconnected with out any reasons some time form Dial-up and
> some times form my LAN  Server side was built with Java and I am
> using TWSocket with our protocol for getting data  My client is
> working fine parsing data and show it to grids.
>
> How can I be sure that my client doest not have a problem ... or ether
> this problem in Server side?
>
> Best Regards.
>
>
> -- 
> 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
>
>

-- 
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


Re: [twsocket] Disconnect

2006-05-04 Thread Wilfried Mestdagh
Hello Abdullah,

You can check winsock error in OnSessionClosed of your client program.
If it does have an error and you never call Close(Delayed) in your
client then you can assume that server close connection.

If you have errorcode then possible it is due to data loss or some
firewall interfering.

You can eventually download SocketSpy (user made page), and modify it to
display witch side is closing.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Thursday, May 4, 2006, 14:46, Abdullah AlQasim wrote:

> Hello All,

> I am newbie with TWSocket  I have some critical problem with my 
> project :

> My client disconnected with out any reasons some time form Dial-up and
> some times form my LAN  Server side was built with Java and I am 
> using TWSocket with our protocol for getting data  My client is 
> working fine parsing data and show it to grids.

> How can I be sure that my client doest not have a problem ... or ether
> this problem in Server side?

> Best Regards.



-- 
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


[twsocket] Disconnect

2006-05-04 Thread Abdullah AlQasim
Hello All,

I am newbie with TWSocket  I have some critical problem with my 
project :

My client disconnected with out any reasons some time form Dial-up and 
some times form my LAN  Server side was built with Java and I am 
using TWSocket with our protocol for getting data  My client is 
working fine parsing data and show it to grids.

How can I be sure that my client doest not have a problem ... or ether 
this problem in Server side?

Best Regards.


-- 
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


Re: [twsocket] Disconnect a client from FTPServer...

2005-10-20 Thread Francois Piette
> I'm trying to code a simple FTPServer using the ICS Demo
> as a base. However, I want to be able to disconnect a user via the
> server. I see the "FtpServer1.Disconnect()" method but I don't know how
> to use it.
> Could someone please explain how I would go about using this,
> for example, in an onClick method of a button. Thanks in Advance.

You must pass the client reference as Disconnect argument.
You get this reference either from one on the events, or you can iterate the 
Client[] property to
find the one you want to disconnect.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be




-- 
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


[twsocket] Disconnect a client from FTPServer...

2005-10-19 Thread Scott
Hi,

This is my first post to the list so I hope I do it right. My question
is as follows: I'm trying to code a simple FTPServer using the ICS Demo
as a base. However, I want to be able to disconnect a user via the
server. I see the "FtpServer1.Disconnect()" method but I don't know how
to use it. Could someone please explain how I would go about using this,
for example, in an onClick method of a button. Thanks in Advance.

Regards,
Scott


-- 
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


Re: [twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Dan
NOOP is a good one.
Dan
- Original Message - 
From: "Francois PIETTE" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Monday, May 16, 2005 2:44 PM
Subject: Re: [twsocket] Disconnect from FTP Server [FTP Client]


>Winsock nor the component will let you know the server disconnected
>before you try to send something. So the solution is to periodically 
>send
a
>command just to get the error in case the server closed the connection.
Note
>that periodically sending a command will probably prevent the server 
>from
>closing the connection because it sees activity.

Thanks a lot. Which command can you advise to send to check if FTP
server is avialable?
Any command that do the less possible processing on the server. PWD and 
SYST
are probably the best choices. SYST is not implemented on all servers.
Probably sending an invalid command could also be good, just to receive 
the
error "unknown command" or trigger the session closed event.

I send "Syst" command (after each one minute), but get an error
thought connection was established.
Which error ? Maybe the server you use doesn't implement that command.
It is possible to get the error when user view some directory -
(command "Pwd") and in the same period of time program send command
"Syst"?
I don't understand what you try to tell me.
--
[EMAIL PROTECTED]
http://www.overbyte.be
--
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

--
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


Re: [twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Francois PIETTE
> > Which error ? Maybe the server you use doesn't implement that
> >command.

> Yes, similar to it. I need again to test my program.

But probably for the purpose of keeping the connection open and knowing when
it is closed, it doesn't matter if the server replies it doesn't know the
command !
--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: "Artem Antonov" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Monday, May 16, 2005 4:43 PM
Subject: Re: [twsocket] Disconnect from FTP Server [FTP Client]


> On Mon, 16 May 2005 15:44:25 +0200
>   "Francois PIETTE" <[EMAIL PROTECTED]> wrote:
> >
> > Any command that do the less possible processing on the server. PWD
> >and SYST
> > are probably the best choices. SYST is not implemented on all
> >servers.
> > Probably sending an invalid command could also be good, just to
> >receive the
> > error "unknown command" or trigger the session closed event.
> >
> >> I send "Syst" command (after each one minute), but get an error
> >> thought connection was established.
> >
> > Which error ? Maybe the server you use doesn't implement that
> >command.
> >
>
> Yes, similar to it. I need again to test my program.
> Thanks for help.
>
> Best regards,
> Artem Antonov.
>
> -- 
> 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
>


-- 
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


Re: [twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Artem Antonov
On Mon, 16 May 2005 15:44:25 +0200
 "Francois PIETTE" <[EMAIL PROTECTED]> wrote:
Any command that do the less possible processing on the server. PWD 
and SYST
are probably the best choices. SYST is not implemented on all 
servers.
Probably sending an invalid command could also be good, just to 
receive the
error "unknown command" or trigger the session closed event.

I send "Syst" command (after each one minute), but get an error
thought connection was established.
Which error ? Maybe the server you use doesn't implement that 
command.

Yes, similar to it. I need again to test my program.
Thanks for help.
Best regards,
Artem Antonov.
--
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


Re: [twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Francois PIETTE
> >Winsock nor the component will let you know the server disconnected
> >before you try to send something. So the solution is to periodically send
a
> >command just to get the error in case the server closed the connection.
Note
> >that periodically sending a command will probably prevent the server from
> >closing the connection because it sees activity.

> Thanks a lot. Which command can you advise to send to check if FTP
> server is avialable?

Any command that do the less possible processing on the server. PWD and SYST
are probably the best choices. SYST is not implemented on all servers.
Probably sending an invalid command could also be good, just to receive the
error "unknown command" or trigger the session closed event.

> I send "Syst" command (after each one minute), but get an error
> thought connection was established.

Which error ? Maybe the server you use doesn't implement that command.

> It is possible to get the error when user view some directory -
> (command "Pwd") and in the same period of time program send command
> "Syst"?

I don't understand what you try to tell me.
--
[EMAIL PROTECTED]
http://www.overbyte.be


-- 
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


Re: [twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Artem Antonov
On Mon, 16 May 2005 14:46:27 +0200
 "Francois PIETTE" <[EMAIL PROTECTED]> wrote:
Winsock nor the component will let you know the server disconnected 
before you try to send something. So the solution is to periodically send a 
command just to get the error in case the server closed the connection. Note 
that periodically sending a command will probably prevent the server from 
closing the connection because it sees activity.

--
[EMAIL PROTECTED]
http://www.overbyte.be
Thanks a lot. Which command can you advise to send to check if FTP 
server is avialable?
I send "Syst" command (after each one minute), but get an error 
thought connection was established.
It is possible to get the error when user view some directory - 
(command "Pwd") and in the same period of time program send command 
"Syst"?

Best regards,
Artem Antonov.
--
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


Re: [twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Francois PIETTE
> 1) Client connects to the FTP server
> 2) After timeout or in the case of connection error FTP server close
> connection
> 3) FTP client recieve (immediately) message that FTP server is not
> avialable
> 4) Other actions on the side of client
>
> How I can realaize the 3) step?
> Does anybody solved such problem and which solutions are avialable?

Winsock nor the component will let you know the server disconnected before
you try to send something. So the solution is to periodically send a command
just to get the error in case the server closed the connection. Note that
periodically sending a command will probably prevent the server from closing
the connection because it sees activity.

--
[EMAIL PROTECTED]
http://www.overbyte.be


-- 
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


[twsocket] Disconnect from FTP Server [FTP Client]

2005-05-16 Thread Artem Antonov
Hello,
I've already written in this maling list about disconnect from FTP 
server in the case when FTP server close connection (how I can control 
this event to disconnect client immediately). Sorry, but I can't 
solving this problem, so I ask help again.

The steps are:
1) Client connects to the FTP server
2) After timeout or in the case of connection error FTP server close 
connection
3) FTP client recieve (immediately) message that FTP server is not 
avialable
4) Other actions on the side of client

How I can realaize the 3) step?
Does anybody solved such problem and which solutions are avialable?
Thanks!
Best regards,
Artem Antonov.
--
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