☆ ''ソケットオプションの設定''
''int'' ''&color(Maroon){setsockopt};'' ''(''
  ''SOCKET'' s,
  ''int'' level,
  ''int'' optname,
  ''const char FAR *'' optval,
  ''int'' optlen
'');''

* &tip; パラメータ [#mc951e75]
''s''
-[in] A descriptor identifying a socket.

''level''
-[in] The level at which the option is defined (for example, SOL_SOCKET).

''optname''
-[in] The socket option for which the value is to be set (for example, SO_BROADCAST). The optname parameter must be a socket option defined within the specified level, or behavior is undefined.

''optval''
-[in] A pointer to the buffer in which the value for the requested option is specified.

''optlen''
-[in] The size, in bytes, of the optval buffer. 

* &tip; 返り値 [#j5078a27]
成功した場合 0 を返しエラーの場合 SOCKET_ERROR を返す

* (--; エラー [#ka1257bf]
WSAENOTINITIALISED
-A successful WSAStartup() must occur before using this API. 

WSAENETDOWN
-The Windows Sockets implementation has detected that the network subsystem has failed. 

WSAEFAULT
-optval is not in a valid part of the process address space. 

WSAEINPROGRESS
-A blocking Windows Sockets operation is in progress. 

WSAEINVAL
-level is not valid, or the information in optval is not valid. 

WSAENETRESET
-Connection has timed out when SO_KEEPALIVE is set.
 
WSAENOPROTOOPT
-The option is unknown or unsupported. In particular, SO_BROADCAST is not supported on sockets of type SOCK_STREAM, while SO_DONTLINGER, SO_KEEPALIVE, SO_LINGER and SO_OOBINLINE are not supported on sockets of type SOCK_DGRAM. 

WSAENOTCONN
-Connection has been reset when SO_KEEPALIVE is set.
 
WSAENOTSOCK
-The descriptor is not a socket.