'C socket programming: What is the condition under which the client receives a connection result event (FD_CONNECT) after the server's accept()?
I am working on Windows 10.
I'm making a simple chat program. As the title suggests, I would like to ask a question regarding the connection of sockets.
I tested by running only one client and one server. The client has one socket to connect to and one ListenSocket. The server has one ListenSocket. Here's the scenario:
The client tried to connect to the server by calling
connect().WSAEWOULDBLOCKwas returned.The server has received
FD_ACCEPT, calledaccept()to accept it, and created a socket corresponding to the connected client and added it to the list.Here I was expecting the client to receive an
FD_CONNECT, but nothing happened. The clients can send chats, and the server can listen. However, the response sent by the server cannot be received by the client.Called
connect()from server to client. The client received bothFD_ACCEPTandFD_CONNECT. Also, the client received a response that the server had sent in the past (FD_READoccurred).
I guessed that the FD_CONNECT event notifying the connection result is an event that occurs only when a two-way connection is made. Also I guessed because when using the MFC socket class the client could receive the server's response by simply calling Connect(): In CAsyncSocket Accept(), not only accepts by calling accept(), but also send connect() to the accepted client.
But MSDN and Google didn't tell me explicitly. Can you confirm if my guess is correct?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
