setsockopt()

Last-modified: 2006-12-10 (日) 02:06:55

[star] ソケットオプションの設定
int setsockopt (
  SOCKET s,
  int level,
  int optname,
  const char FAR * optval,
  int optlen
);

[tip] パラメータ

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] 返り値

成功した場合 0 を返しエラーの場合 SOCKET_ERROR を返す

(--; エラー

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.