Document revision date: 15 July 2002 | |
Previous | Contents | Index |
Accepts a connection on a socket.
#include <socket.h>Routine Variants The accept routine has a variant named __bsd44_accept . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.int accept (int s, struct sockaddr *addr, int *addrlen);
(_DECC_V4_SOURCE) int accept (int s, struct sockaddr *addr, size_t *addrlen);
(NOT _DECC_V4_SOURCE)
s
A socket descriptor that has been returned by socket , subsequently bound to an address with bind , and that is listening for connections after a listen .addr
A result parameter that is filled in with the address of the connecting entity, as known to the communications layer. The exact format of the structure to which the address parameter points is determined by the domain in which the communication is occurring. This version of Compaq C supports only the Internet domain (AF_INET).addrlen
A value-result parameter; it should initially contain the size of the structure pointed to by addr. On return it will contain the actual length, in bytes, of the structure that has been filled in by the communication layer. See <socket.h> for a description of the sockaddr structure.
The accept routine completes the first connection on the queue of pending connections, creates a new socket with the same properties as s, and allocates and returns a new descriptor for the socket. If no pending connections are present on the queue, and the socket is not marked as nonblocking, accept blocks the caller until a connection request is present. If the socket is marked nonblocking by using a setsockopt call and no pending connections are present on the queue, accept returns an error. The accepted socket may not be used to accept connections. The original socket s remains open (listening) for other connection requests. This call is used with connection-based socket types, currently with SOCK_STREAM.It is possible to select a socket for the purposes of performing an accept by selecting it for read.
See also bind , connect , listen , select , and socket in this appendix.
x A nonnegative integer that is a descriptor for the accepted socket. - 1 Indicates an error; errno is set to one of the following:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- EOPNOTSUPP -- The reference socket is not of type SOCK_STREAM.
- EFAULT -- The addr parameter is not in a writable part of the user address space.
- EWOULDBLOCK -- The socket is marked nonblocking and no connections are present to be accepted.
Binds a name to a socket.
#include <socket.h>Routine Variants The bind routine has a variant named __bsd44_bind . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.int bind (int s, struct sockaddr *name, int namelen);
(_DECC_V4_SOURCE) int bind (int s, const struct sockaddr *name, size_t namelen);
(NOT _DECC_V4_SOURCE)
s
A socket descriptor that has been created with socket .name
Address of a structure used to assign a name to the socket in the format specific to the family (AF_INET) socket address. See <socket.h> for a description of the sockaddr structure.namelen
The size, in bytes, of the structure pointed to by name.
The bind routine assigns a name to an unnamed socket. When a socket is created with socket it exists in a name space (address family) but has no name assigned. The bind routine requests that a name be assigned to the socket.See also connect , getsockname , listen , and socket in this appendix.
0 Indicates success. - 1 Indicates an error; errno is set to one of the following values:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- EADDRNOTAVAIL -- The specified address is not available from the local machine.
- EADDRINUSE -- The specified Internet address and ports are already in use.
- EINVAL -- The socket is already bound to an address.
- EACCESS -- The requested address is protected, and the current user has inadequate permission to access it.
- EFAULT -- The name parameter is not a valid part of the user address space.
Closes a connection and deletes a socket descriptor.
#include <unixio.h>int close (s);
s
A socket descriptor.
The close routine deletes a descriptor from the per-process object reference table. If this is the last reference to the underlying object, then it will be deactivated.See also accept , socket , and write in this appendix.
0 Indicates success. - 1 Indicates an error; errno is set to EBADF (The socket descriptor is invalid.)
Initiates a connection on a socket.
#include <socket.h>Routine Variants The connect routine has a variant named __bsd44_connect . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.int connect (int s, struct sockaddr *name, int namelen);
(_DECC_V4_SOURCE) int connect (int s, const struct sockaddr *name, size_t namelen);
(NOT _DECC_V4_SOURCE)
s
A socket descriptor that has been 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 to which data is to be sent. If it is of type SOCK_STREAM, then this call attempts to make a connection to another socket.Each communications space interprets the name parameter in its own way. This argument specifies the socket to which the socket specified in s is to be connected.
See also accept , select , socket , getsockname , and shutdown in this appendix.
0 Indicates success. - 1 Indicates an error; errno is set to one of the following:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- EADDRNOTAVAIL -- The specified address is not available from the local machine.
- EAFNOSUPPORT -- Address in the specified address family cannot be used with this socket.
- EISCONN -- The socket is already connected.
- ETIMEOUT -- Connection establishment timed out without establishing a connection.
- ECONNREFUSED -- The attempt to connect was forcefully rejected.
- ENETUNREACH -- The network is not reachable from this host.
- EADDRINUSE -- The specified Internet address and ports are already in use.
- EFAULT -- The name parameter is not a valid part of the user address space.
- EWOULDBLOCK -- The socket is nonblocking and the connection cannot be completed immediately. It is possible to select the socket while it is connecting by selecting it for writing.
Returns the Socket Device Channel (SDC) associated with a socket descriptor for direct use with the TCP/IP Services for OpenVMS product.
#include <socket.h>short int decc$get_sdc (int s);
s
A socket descriptor.
The decc$get_sdc routine returns the SDC associated with a socket. C socket descriptors are normally used either as file descriptors or with one of the routines that take an explicit socket descriptor as its argument. C sockets are implemented using TCP/IP Services for OpenVMS Socket Device Channels. This routine returns the SDC used by a given socket descriptor so that you can use the TCP/IP Services for OpenVMS's facilities directly by means of various I/O system services ($QIO).
0 Indicates that s is not an open socket descriptor. x The SDC number.
Closes host database file.
#include <netdb.h>void endhostent (void);
The endhostent routine closes the network host database file, previously opened with the gethostbyaddr or gethostbyname routine.See also gethostbyaddr , and gethostbyname in this appendix.
If the endhostent routine does not exist in your TCP/IP library, then errno is set to ENOSYS.
Closes the networks database file.
#include <netdb.h>void endnetent (void);
The endentent routine closes the networks database file, previously opened with the getnetent , setnetent , getnetbyaddr , or getnetbyname routine.See also getnetent , getnetbyaddr , getnetbyname , and setnetent in this appendix.
If the endnetent routine does not exist in your TCP/IP library, then errno is set to ENOSYS.
Closes the protocols database file.
#include <netdb.h>void endprotoent (void);
The endprotoent routine closes the network protocols database file, previously opened with the getprotoent , getprotobyname , or getprotobynumber routine.See also getprotobyname , getprotoent , and getprotobynumber in this section.
If the endprotoent routine does not exist in your TCP/IP library, then errno is set to ENOSYS.
Closes the network services database file.
#include <netdb.h>void endservent (void);
The endservent routine closes the network services database file, previously opened with the getservent , getservbyname , or getservbyport routine.See also getservent , getservbyname , and getservbyport in this appendix.
If the endservent routine does not exist in your TCP/IP library, then errno is set to ENOSYS.
Returns the standard host address for the processor.
#include <socket.h>int gethostaddr (char *addr);
addr
A pointer to the buffer in which the standard host address for the current processor is returned.
This system call returns the standard host address for the current processor. The returned address is null-terminated. The addr parameter must point to at least 16 bytes of free space.Host addresses are limited to 16 characters.
0 Indicates success. - 1 Indicates that an error has occurred and is further specified in the global errno .
Searches the host database sequentially from the beginning of the database for a host record with a given address.
#include <netdb.h>Routine Variants The gethostbyaddr routine has a variant named __bsd44_gethostbyaddr . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.struct hostent *gethostbyaddr (char *addr, int len, int type);
addr
A pointer to a series of bytes in network order specifying the address of the host sought. This argument does not point to an ASCII string.len
The number of bytes in the address pointed to by the addr argument.type
The type of address format being sought. Currently, only AF_INET (defined in <socket.h> ) is supported.)
The gethostbyaddr routine finds the first host record in the host database with the given address.This routine uses a common static area for its return values. This means that subsequent calls this routine will overwrite any existing host entry. You must make a copy of the host entry if you wish to save it.
NULL Indicates an error. x A pointer to an object having the hostent structure. See <netdb.h> for a description of the hostent structure. Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See Sections A.5 and A.6.)
Searches the host database sequentially from the beginning of the database for a host record with a given name or alias.
#include <netdb.h>Routine Variants The gethostbyname routine has a variant named __bsd44_gethostbyname . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.struct hostent *gethostbyname (char *name);
name
A pointer to a null-terminated character string containing the name or an alias of the host sought.
The gethostbyname routine finds the first host in the host database with the given name or alias.This routine uses a common static area for its return values. This means that subsequent calls to this routine will overwrite any existing host entry. You must make a copy of the host entry if you wish to save it.
NULL Indicates an error. x A pointer to an object having the hostent structure. See <netdb.h> for a description of the hostent structure. Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See Sections A.5 and A.6.)
Gets a host file entry from the network host database file.
#include <netdb.h>struct hostent *gethostent (void);
The gethostent routine reads the next entry of the database, opening a connection to the database, if necessary.See the <netdb.h> header file for a description of the hostent structure.
This routine uses a common static area for its return values. Therefore, subsequent calls to this routine overwrite any existing network entry. You must make a copy of the network services entry, if you wish to save it.
x A pointer to the hostent structure. NULL Indicates an error.
Returns the name currently associated to the host.
#include <socket.h>int gethostname (char *name, int namelen);
(_DECC_V4_SOURCE) int gethostname (char *name, size_t namelen);
(NOT _DECC_V4_SOURCE)
name
The address of a buffer into which the name should be written. The returned name is null-terminated unless sufficient space is not provided.namelen
The size of the buffer pointed to by name.
The gethostname routine returns the hostname maintained by the TCP/IP Services for OpenVMS or compatible TCP/IP product.
0 Indicates success. - 1 Indicates an error; errno is set to one of the following:
- EFAULT -- The buffer decribed by name and namelen is not a valid, writable part of the user address space.
- EINVAL -- The returned name is an invalid address.
Previous | Next | Contents | Index |
privacy and legal statement | ||
5763PRO_067.HTML |