Home > Software engineering >  FD_ACCEPT and FD_CONNECT which triggered first
FD_ACCEPT and FD_CONNECT which triggered first

Time:09-23

FD_ACCEPT and FD_CONNECT which fires first, I said look FD_ACCEPT trigger first, but why do I always jump to FD_CONNECT when debugging?

CodePudding user response:

You concept mistaken
Based on the TCP (connection-oriented) socket programming, divided into client and server,
The client process is as follows:
(1) to create a socket (socket)
(2) send a connection request to the server (connect)
(3) and server communicate (send/recv)
(4) close the socket
The server process is as follows:
(1) to create a socket (socket)
(2) to bind a socket to a local address and port (bind)
(3) to the socket set to monitor mode, ready to receive the client request (listen)
(4) waiting for customer request; When the request arrives, accept connection requests and returns a new corresponding to the connection socket (accept)
(5) with return the socket and the client communicate (send/recv)
(6) return, waiting for another client request,
Close the socket (7),

CodePudding user response:

reference 1st floor u011001084 response:
wrong concepts you
Based on the TCP (connection-oriented) socket programming, divided into client and server,
The client process is as follows:
(1) to create a socket (socket)
(2) send a connection request to the server (connect)
(3) and server communicate (send/recv)
(4) close the socket
The server process is as follows:
(1) to create a socket (socket)
(2) to bind a socket to a local address and port (bind)
(3) to the socket set to monitor mode, ready to receive the client request (listen)
(4) waiting for customer request; When the request arrives, accept connection requests and returns a new corresponding to the connection socket (accept)
(5) with return the socket and the client communicate (send/recv)
(6) return, waiting for another client request,
Close the socket (7),


This process, I know, I wanted to know whether the client to connect, then the service side trigger FD_ACCEPT message, the server after the accept function called client trigger FD_CONNECT message again?

CodePudding user response:

Server waiting for the client Connect to accept the connection request to accept

CodePudding user response:

The one on the Server in the Client

CodePudding user response:

FD_ACCEPT:
The When WSAAsyncSelect called, if there is currently a connection request available to accept.
When a connection request arrives, the if FD_ACCEPT not already posted.
After the accept called, if there is another connection request available to accept.

FD_CONNECT:
The When WSAAsyncSelect called, if there is currently a connection established.
After connect called, when the connection is established, even when the connect succeeds, as is typical with a datagram socket.
After calling WSAJoinLeaf, the when the join operation of.
After connect, WSAConnect, or WSAJoinLeaf was called with a from, connection - oriented socket. The initial operation returned with a specific error of WSAEWOULDBLOCK, but The network operation went ahead, been The operation eventually succeeds or not, The when The outcome has had been determined, FD_CONNECT happens. The client should check The error code to determine been The outcome was successful or failed.

CodePudding user response:

Accept is waiting for the connection of meaning, so accept is prior to connect, such as connection after the completion of the night ended the connect again,

CodePudding user response:

FD_ACCEPT and FD_CONNECT two event trigger
  • Related