VMS Help
TCPIP Services, Programming Interfaces, Sockets API, connect()
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Initiates a connection on a socket.
The $QIO equivalent is the IO$_ACCESS function.
Format
#include <types.h>
#include <socket.h>
int connect ( int s, struct sockaddr *name, int namelen );
s
A socket descriptor created with socket().
name
The address of a structure that specifies the name of the remote
socket in the format specific to the address family (AF_INET).
namelen
The size, in bytes, of the structure pointed to by name.
If s is a socket descriptor of type SOCK_DGRAM, then this call
permanently specifies the peer where the data is sent. If s is of
type SOCK_STREAM, then this call attempts to make a connection to
the specified socket.
Each communications space interprets the name argument. This
argument specifies the socket that is connected to the socket
specified in s.
If the connect() function fails for a connection-mode socket,
applications should use the close() function to deallocate
the socket and descriptor. If attempting to reinitiate the
connection, applications should create a new socket.
Related Functions
See also accept(), select(), socket(), getsockname(), and
shutdown().
0 Successful completion.
-1 Error; errno is set to indicate the error.
EADDRINUSE Configuration problem. There are insufficient
ports available for the attempted connection.
The ipport_userreserved variable of the inet
subsystem should be increased.
EADDRNOTAVAIL The specified address is not available from
the local machine.
EAFNOSUPPORT The addresses in the specified address family
cannot be used with this socket.
EALREADY A connection request is already in progress
for the specified socket.
EBADF The socket descriptor is invalid.
ECONNREFUSED The attempt to connect was rejected.
EFAULT The name argument is not a valid part of the
user address space.
EHOSTUNREACH The specified host is not reachable.
EINPROGRESS O_NONBLOCK is set for the file descriptor
for the socket, and the connection cannot be
immediately established; the connection will
be established asynchronously.
EINTR The connect() function was interrupted by a
signal while waiting for the connection to be
established. Once established, the connection
may continue asynchronously.
EINVAL The value of the namelen argument is invalid
for the specified address family, or the sa_
family field in the socket address structure
is invalid for the protocol.
EISCONN The socket is already connected.
ELOOP Too many symbolic links were encountered in
translating the file specification in the
address.
ENETDOWN The local network connection is not
operational.
ENETUNREACH No route to the network or host is present.
ENOBUFS The system has insufficient resources to
complete the call.
ENOTSOCK The socket descriptor is invalid.
EOPNOTSUPP The socket is listening and cannot be
connected.
EPROTOTYPE The specified address has a different type
than the socket bound to the specified peer
address.
ETIMEDOUT The connection request timed out without
establishing a connection.
EWOULDBLOCK The socket is nonblocking, and the connection
cannot be completed immediately. It is
possible to use the select() function to
select the socket for writing.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.