Questions about WinSock TCP/IP.

Questions about WinSock TCP/IP.

Postby yunbg1 » Fri Oct 20, 2006 6:49 pm

Hi all.

Questions about WinSock TCP/IP.

We are Server, others are Clients.

Clients can send message to server.

How can server send a message to specific client ?

How does server send a message to client anytime ?

Thanks.

yunbg.

FWH USER.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby reinaldocrespo » Sat Oct 21, 2006 6:36 pm

Yunbg1;

I'm no expert but I'm currently doing it via a tsocket connection. Communication is both ways with a TCP/IP socket connection.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sat Oct 21, 2006 6:48 pm

Yubg,

oClient:SendData( ... )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Sun Oct 22, 2006 9:05 pm

Hello Antonio.

Thank you.

..
Last edited by yunbg1 on Mon Oct 23, 2006 9:48 pm, edited 2 times in total.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby yunbg1 » Mon Oct 23, 2006 1:53 am

Hello Mr. Antonio

Thank you for answer my questions.

1. Ex.1 code is available.
2. Ex.2 code is not available.

Ex.1 (oClient:bWrite) is working.
oClient:bWrite := { | oClient | OnConnect( oClient ) } <- Here

Ex.2 (oClient:bConnect) is not working. Why it does not work ?
oClient:bConnect := { | oClient | OnConnect( oClient ) }
Client does not have METHOD of bConnect ?

-------------------------------------------------------------------------------------
1. Ex.1 code is available.
-------------------------------------------------------------------------------------

EX 1]

Code: Select all  Expand view
oSocket := TSocket():New( 8000 )
oSocket:cLogFile := "c:\tcpip.txt"
oSocket:lDebug := .t.

oSocket:bAccept := { | oSocket | ;
               oClient := TSocket():Accept( oSocket:nSocket ),;
               oClient:Cargo := ST_COMMAND,;
               oClient:bRead := { | oSocket | OnRead1( oSocket ) },;
               oClient:bWrite := { | oClient | OnConnect( oClient ) },; <- Here
               oClient:bClose := { | oSocket | OnClose1( oSocket ) } }

oSocket:Listen()

//-----------------------------------------------------------------------------------
FUNC OnConnect(oClient)
oField[01]:Append( time()+ str(oClient:nSocket,5) + " : Client Connect..." + CRLF, 1)
RETU NIL



[View 'C:\tcpip.txt' Code]

10/23/06 09:59:28: Accept Socket handle: 1892
10/23/06 09:59:28: Write Socket handle: 1860
10/23/06 09:59:28: Write Socket handle: 1860



-------------------------------------------------------------------------------------
2. Ex.2 code is not available.
-------------------------------------------------------------------------------------

EX 2]

Code: Select all  Expand view
oSocket := TSocket():New( 8000 )
oSocket:cLogFile := "c:\tcpip.txt"
oSocket:lDebug := .t.

oSocket:bAccept := { | oSocket | ;
                       oClient := TSocket():Accept( oSocket:nSocket ),;
                       oClient:Cargo := ST_COMMAND,;
                       oClient:bRead := { | oSocket | OnRead1( oSocket ) },;
                       oClient:bConnect := { | oClient | OnConnect( oClient ) },; <- Here
                       oClient:bClose := { | oSocket | OnClose1( oSocket ) } }

oSocket:Listen()

//-----------------------------------------------------------------------------------
FUNC OnConnect(oClient)
oField[01]:Append( time()+ str(oClient:nSocket,5) + " : Client Connect..." + CRLF, 1)
RETU NIL



yunbg.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 62 guests