[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2


socks5tcp_accept Subroutine

Purpose

Awaits an incoming connection to a socket from a previous socks5tcp_bind() call.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <sys/socket.h>
#include <socks5_api.h>

int socks5tcp_accept(Socket, Dst, DstLen, Svr, SvrLen)
int Socket;
struct sockaddr *Dst;
size_t DstLen;
struct sockaddr *Svr;
size_t SrvLen;

Description

The socks5tcp_accept subroutine blocks until an incoming connection is established on a listening socket that was requested in a previous call to socks5tcp_bind. Upon success, subsequent writes to and reads from Socket will be relayed through Svr.

Socket must be an open socket descriptor of type SOCK_STREAM.

Parameters


Socket Specifies the unique name of the socket.
Dst If non-NULL, buffer for receiving the address of the remote client which initiated an incoming connection
DstLength Specifies the length of the address structure in Dst.
Svr If non-NULL, specifies the address of the SOCKSv5 server to use to request the relayed connection; on success, this space will be overwritten with the server-side address of the incoming connection.
SvrLength Specifies the length of the address structure in Svr.

Return Values

Upon successful completion, the socks5tcp_accept subroutine returns a value of 0, and modifies Dst and Svr to reflect the actual endpoints of the incoming external socket.

If the socks5tcp_accept subroutine is unsuccessful, the system handler performs the following functions:

Error Codes (placed in errno; inherited from underlying call to connect())

The socks5tcp_bindaccept subroutine is unsuccessful if any of the following errors occurs:

EBADF The Socket parameter is not valid.
EAFNOSUPPORT The addresses in the specified address family cannot be used with this socket.
ENETUNREACH No route to the network or host is present.
EFAULT The Dst or Svr parameter is not in a writable part of the user address space.
EINVAL One or more of the specified arguments is invalid.
ENETDOWN The specified physical network is down.
ENOSPC There is no space left on a device or system table.
ENOTCONN The socket could not be connected.

Error Codes (placed in socks5_errno; SOCKSv5-specific errors)

The socks5tcp_connect subroutine is unsuccessful if any of the following errors occurs:

S5_ESRVFAIL General SOCKSv5 server failure.
S5_EPERM SOCKSv5 server ruleset rejection.
S5_ENETUNREACH SOCKSv5 server could not reach target network.
S5_EHOSTUNREACH SOCKSv5 server could not reach target host.
S5_ECONNREFUSED SOCKSv5 server connection request refused by target host.
S5_ETIMEDOUT SOCKSv5 server connection failure due to TTL expiry.
S5_EOPNOTSUPP Command not supported by SOCKSv5 server.
S5_EAFNOSUPPORT Address family not supported by SOCKSv5 server.
S5_EADDRINUSE Requested bind address is already in use (at the SOCKSv5 server).
S5_ENOSERV No server found.

Examples

The following program fragment illustrates the use of the socks5tcp_accept and socks5tcp_bind subroutines by a client to request a listening socket from a server and wait for an incoming connection on the server side.

struct sockaddr_in svr;
struct sockaddr_in dst;
.
.
.
socks5tcp_bind(s,(struct sockaddr*)&dst, sizeof(dst), (struct sockaddr *)&svr, sizeof(svr), &res, sizeof(svr));
.
.
.
socks5tcp_accept(s, (struct sockaddr *)&dst, sizeof(dst), (struct sockaddr *)&svr, sizeof(svr)); 

Implementation Specifics

The socks5tcp_accept subroutine is part of Base Operating System (BOS) Runtime.

The socket applications can be compiled with COMPAT_43 defined. This will make the sockaddr structure BSD 4.3 compatible. For more details refer to socket.h.

Related Information

The socks5tcp_connect subroutine, socks5tcp_bind subroutine, socks5udp_associate subroutine, socks5udp_sendto subroutine, socks5_getserv subroutine, /etc/socks5c.conf file, accept subroutine, bind subroutine, getsockname subroutine, send subroutine, socket subroutine.

Initiating UNIX Stream Connections Example Program, Sockets Overview, and Understanding Socket Connections in AIX 5L Version 5.1 Communications Programming Concepts.

SOCKS5C_CONFIG Environment Variable in AIX 5L Version 5.1 Files Reference.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]