I have a Problem in my programming in winsock porgramming. In the program, I try to implement communication between a client and a server so I put the functions of server's and client's together. By running two separate processes independently, one play a role as a server and the others as a client. After establishing the connection between them successfully,
the server fail to send the data to the client. However the client can send the data to the server successfully. That make me confused. Hope to get help from anybody who can set it.
The method in my program is as follows:
1 Establishing the server-side socket by running member functions of CAsyncSocket: create(Port) and Listen();
2 Establishing the client-side socket by running member functions of CAsyncSockte: create() and Listen(IPAddr,Port);(Looks successfully by get echo from server's OnAccept() and client's OnConnect() ).
3 Client send data to Server. (No echo from server's OnReceive());
4 Server send data to client. (Get echo from client's OnRecieve() and data).
The step 3 always doesn't work. I don't know why.
Can anybody do me a favor?
There are many good reasons why you might be doing this, but the more normal model (as in HTTP, SMTP, POP3 etc., though not non-passive FTP) is that the server creates a socket, and listens, and clients connect to that socket. In other words: the server uses a create() function and a listen() function, and the client uses a create() function and a connect() function. You've then got a bi-directional pipe which either party can use to send data down.
It's unusual for both parties to create a listening socket, and it would be easier to help if we knew why you're doing this.