WSAAsyncSelect 수필

The WSAAsyncSelect function automatically sets socket s to nonblocking mode, regardless of the value of lEvent.

전에 사용하던 코드를 살펴보니 FD_WRITE 플래그를 사용하지 않는다.
왜 사용 안하나? - 소켓 송신 버퍼가 FULL 이 아닐때 계속 신호가 오니깐, 거의 계속해서 신호가 오겠군, 이게 답인가?
하기사 클라이언트가 서버로 보내면 얼마나 보낼것인가~

틀렸다. FD_WRITE는 쓰기 불능 상태에서 가능 상태로 전이가 일어났을때 생긴다고 한다.
찾았다!

The FD_WRITE event is handled slightly differently. An FD_WRITE message is posted when a socket is first connected with connect or WSAConnect (after FD_CONNECT, if also registered) or accepted with accept or WSAAccept, and then after a send operation fails with WSAEWOULDBLOCK and buffer space becomes available. Therefore, an application can assume that sends are possible starting from the first FD_WRITE message and lasting until a send returns WSAEWOULDBLOCK. After such a failure the application will be notified that sends are again possible with an FD_WRITE message.

WSAEWOULDBLOCK
This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later.

send() 함수 호출시 송신용 소켓버퍼가 가득 차있다면 WSAEWOULDBLOCK이 리턴되는 모양이다. 따라서 보다 안정적인 송신을 위해서는 송신용 데이터도 환형큐에 넣고 FD_WRITE가 왔을때 송신 허락 플래그를 On으로 세팅하고 다시 WSAEWOULDBLOCK이 리턴되면 플래그를 Off로 설정해야겠다.


트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://grayowl.egloos.com/tb/1758803 [도움말]

덧글

덧글 입력 영역