How can I use TSocket connect to Server (TCP/IP) automatic?

How can I use TSocket connect to Server (TCP/IP) automatic?

Postby dutch » Thu Dec 28, 2006 9:44 am

Dear Antonio,

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  Expand view
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
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How can I use TSocket connect to Server (TCP/IP) automat

Postby Enrico Maria Giordano » Thu Dec 28, 2006 1:12 pm

dutch wrote:
Code: Select all  Expand view
   ACTIVATE WINDOW oWnd ;
       ON PAINT (Client(cIPAdd))


This is not right. Replace it with

Code: Select all  Expand view
   ACTIVATE WINDOW oWnd ;
       ON INIT (Client(cIPAdd))


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8307
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby dutch » Fri Dec 29, 2006 5:54 am

Thanks Enrico,

It works well.

Best regards,
Dutch
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 7 guests