Re: [twsocket] Check Remote Port

2016-08-24 Thread Charalampos Michael
Although I didn't want to use a component at designtime I used your advice
and seems to work great! Thanks!

-Original Message-
From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Dod
Sent: Thursday, July 21, 2016 10:42 PM
To: ICS support mailing <twsocket@lists.elists.org>
Subject: Re: [twsocket] Check Remote Port

Hello,

Why don't you use events ? ICS is so good event oriented.

regards.

ccg> Hello,
ccg>Is there any easier way to check if a port is open on a remote 
ccg> server at runtime ?

ccg> var
ccg>SocketError: Integer;

ccg> procedure TForm1.SessionConnected(Sender: TObject; ErrCode: Word); 
ccg> begin
ccg>SocketError := ErrCode;
ccg> end;

ccg> procedure TForm1.Button1Click(Sender: TObject); var
ccg>WSocket: TWSocket;
ccg>Loop: Integer;
ccg> begin
ccg>WSocket := twsocket.create(nil);
ccg>WSocket.OnSessionConnected := SessionConnected;
ccg>WSocket.Connect;

ccg>Loop := 0;

ccg>while Loop < 1000 do
ccg>begin
ccg>  Application.ProcessMessages;
ccg>  Sleep(10);
ccg>  Inc(Loop, 10);
ccg>end;

ccg>Caption := IntToStr(SocketError); // WSocket.LastError = 0 ???
ccg>FreeAndNil(WSocket);
ccg> end;

ccg> Thank you !!!


  mailto:do...@yahoo.com

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

-- 
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] Check Remote Port

2016-07-22 Thread François Piette
 >   Is there any easier way to check if a port is open on a remote server
at runtime ?

The only reliable way to check for open port is to try to connect to it. If
you get error 10061, then the port is not opened at server side.

Btw: In you code, it is better to not use a wait loop. Instead use the event
OnSessionConnected and check the error there.


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