I try to connect SockCli.exe to SockServ.exe automatic when activate Main Window but It cannot connect.
Has it a way to connect server automatically (Without user activate manually)
Best regards,
Dutch
Code: Select all
function Main(cIPAdd)
local oBar
Default cIPAdd := '192.168.0.238'
DEFINE WINDOW oWnd TITLE "Client socket "+cIPAdd
DEFINE BUTTONBAR oBar OF oWnd _3D
// DEFINE BUTTON OF oBar ACTION Client(cIPAdd) TOOLTIP "Connect"
DEFINE BUTTON OF oBar ;
ACTION oSocket:SendData( "MSG This is a test" ) ;
TOOLTIP "Send data"
DEFINE BUTTON OF oBar ;
ACTION SendFile() TOOLTIP "Send file"
ACTIVATE WINDOW oWnd ;
ON PAINT (Client(cIPAdd))
return nil
//---------------------------//
function Client(cIPAdd)
oSocket = TSocket():New( 2000 )
oSocket:bRead = { | oSocket | MsgInfo( oSocket:GetData() ) }
// Never use a MsgInfo() here because it hangs Windows!!!
oSocket:bConnect = { || oWnd:SetText( "Connected!" ) }
oSocket:bClose = { || MsgInfo( "Server has closed!" ) }
oSocket:Connect( cIPAdd ) // use the server IP address here
return nil