zouying
asked on
How to use WinSock ?
I am a learner Winsock,got some questions in CAsyncSocket,
1) I derive my own class from CAsyncClass, I send data from ther server side, but the OnSend are never invoked, Why?
2) Could anybody show me the sequence when using CAsyncSocket? Say, in the serve side, If I want to send sth after receive sth, how to call?
Thanks so much.
1) I derive my own class from CAsyncClass, I send data from ther server side, but the OnSend are never invoked, Why?
2) Could anybody show me the sequence when using CAsyncSocket? Say, in the serve side, If I want to send sth after receive sth, how to call?
Thanks so much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mhhh,
I think you are on the wrong way with the "OnSend" method ...
the appropiate method is OnReceive which is called when data receives.
Ok, step by step (client):
1. create a socket object
CSocket mySock;
mySock.Create();
2. connect to server:
mySock.Connect("myserver.d omain.com" , 1048);
perhaps you should call mySock.AsyncSelect(FD_READ |FD_WRITE| FD_CONNECT |FD_CLOSE| FD_OOB|FD_ ACCEPT)
3. now you can send data from client to server:
mySock.Send("hello world", 11);
(on the server side "OnReceive" is called to signal that data is received)
hpoe this makes it more clear.
I think you are on the wrong way with the "OnSend" method ...
the appropiate method is OnReceive which is called when data receives.
Ok, step by step (client):
1. create a socket object
CSocket mySock;
mySock.Create();
2. connect to server:
mySock.Connect("myserver.d
perhaps you should call mySock.AsyncSelect(FD_READ
3. now you can send data from client to server:
mySock.Send("hello world", 11);
(on the server side "OnReceive" is called to signal that data is received)
hpoe this makes it more clear.
You can also look at http://www.winsite.com/info/pc/win95/programr/socktst3.zip/downl.html
this is a complete socket client (with MFC source!).
this is a complete socket client (with MFC source!).
ASKER