connect()

Last-modified: 2006-12-10 (日) 02:10:48

[star] ソケットの接続
int connect (
  SOCKET s,
  const struct sockaddr * name,
  int namelen
);

[tip] パラメータ

s

  • [in] 接続されていないソケットを指定

name

  • [in] 接続先のアドレスをsockaddr構造体で指定

namelen

  • [in] パラメータnameの長さを指定

[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.

WSAEADDRINUSE

  • The specified address is already in use.

WSAEINTR

  • The (blocking) call was canceled via WSACancelBlockingCall()

WSAEINPROGRESS

  • A blocking Windows Sockets call is in progress.

WSAEADDRNOTAVAIL

  • The specified address is not available from the local machine.

WSAEAFNOSUPPORT

  • Addresses in the specified family cannot be used with this socket.

WSAECONNREFUSED

  • The attempt to connect was forcefully rejected.

WSAEDESTADDREQ

  • A destination address is required.

WSAEFAULT

  • The namelen argument is incorrect.

WSAEINVAL

  • The socket is not already bound to an address.

WSAEISCONN

  • The socket is already connected.

WSAEMFILE

  • No more file descriptors are available.

WSAENETUNREACH

  • The network can't be reached from this host at this time.

WSAENOBUFS

  • No buffer space is available. The socket cannot be connected.

WSAENOTSOCK

  • The descriptor is not a socket.

WSAETIMEDOUT

  • Attempt to connect timed out without establishing a connection

WSAEWOULDBLOCK

  • The socket is marked as non-blocking and the connection cannot be completed immediately. It is possible to select() the socket while it is connecting by select()ing it for writing.