Difference between revisions of "TWSocket.Connect"
Jump to navigation
Jump to search
m |
|||
Line 1: | Line 1: | ||
This method try to connect to remote Server. | This method try to connect to remote Server. | ||
− | Whenever OnSessionClosed event will be fired is case on problem during | + | Whenever OnSessionClosed event will be fired is case on problem during connection, you may get exception error just right after the .Connect if you did not (re)filled .Port and .Addr values before calling .Connect or you'll raise an exception. |
− | You may also get exception if you have some local socket problem (i.e a blocking firewall not allowing | + | You may also get an exception if you have some local socket problem (i.e a blocking firewall not allowing your application to create outgoing socket). |
Here is a sample of connecting, you can also read .OnSessionClosed to get more info about this sample. | Here is a sample of connecting, you can also read .OnSessionClosed to get more info about this sample. |
Revision as of 18:07, 10 April 2006
This method try to connect to remote Server.
Whenever OnSessionClosed event will be fired is case on problem during connection, you may get exception error just right after the .Connect if you did not (re)filled .Port and .Addr values before calling .Connect or you'll raise an exception.
You may also get an exception if you have some local socket problem (i.e a blocking firewall not allowing your application to create outgoing socket).
Here is a sample of connecting, you can also read .OnSessionClosed to get more info about this sample.
WM_CONNECT2SERVER: begin try if WSocket2Server.State <> wsClosed then WSocket2Server.close; inc(WSocket2Server.RetryCount); WSocket2Server.Port:=StringListConfigFile.Values['ServerPort']; WSocket2Server.Addr:=StringListConfigFile.Values['ServerAddr']; WSocket2Server.Connect; except // Yes you may have an error with no SessionClosed // For example if a local firewall is blocking socket on E: Exception do begin LogConnector(E.Message); if TimeSetEvent(WSocket2Server.RetryDelay,100,@TimeCallBackReconnect,0,TIME_ONESHOT)=0 then LogConnector('TimeSetEvent creation error'); // WSocket2Server.RetryDelay may be altered if Server // sent some 'server will be off for xxx minutes' // just before a clean close end; end; end;