LINGER lingerStruct;

 

lingerStruct.l_onoff = 1;
lingerStruct.l_linger = 0; // 대기 없이 바로 종료, blocking 대기시간

 

setsockopt(clientS, SOL_SOCKET, SO_LINGER, (char *)&lingerStruct, sizeof(lingerStruct));

 

=======================================================================================

 

소켓을 닫을때 아직 미전송된 데이타가 있으면 다 보낼때까지 blocking되도록 한다.

 

If SO_DONTLINGER is set on a stream socket by setting the l_onoff member of the LINGER structure to zero, the closesocket call will return immediately and does not receive WSAWOULDBLOCK whether the socket is blocking or nonblocking. However, any data queued for transmission will be sent, if possible, before the underlying socket is closed. This is also called a graceful disconnect. In this case, the Windows Sockets provider cannot release the socket and other resources for an arbitrary period, thus affecting applications that expect to use all available sockets. This is the default behavior (SO_DONTLINGER is set by default).

'Development > 네트워크 프로그래밍' 카테고리의 다른 글

shutdown 함수  (0) 2011.08.13
Microsoft Windows 2000 TCP/IP 구현 정보  (0) 2011.08.13
IP String -> DWORD 로 변환  (0) 2011.08.13
IOCP 예제 코드  (0) 2011.08.13
Graceful shutdown  (0) 2011.08.13
안정적인 DNS서비스 DNSEver DNS server, DNS service
Posted by 키르히아이스
,