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.
Questions about WinSock TCP/IP.
Questions about WinSock TCP/IP.
FWH User
FWPPC User
FWLinux User
FWPPC User
FWLinux User
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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]
[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]
yunbg.
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
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
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
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
FWPPC User
FWLinux User