[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

socks5udp_associate Subroutine

Purpose

Connects to a SOCKSv5 server, and requests a UDP association for subsequent UDP socket communications.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <sys/socket.h>
#include <socks5_api.h>
int socks5udp_associate (Socket, Dst, DstLen, Svr, SvrLen)
int Socket;
const struct sockaddr *Dst;
size_t DstLen;
const struct sockaddr *Svr;
size_t SrvLen;

Description

The socks5udp_associate subroutine requests a UDP association for Dst on the SOCKSv5 server specified in Svr. Upon success, Dst is overwritten with a rendezvous address to which subsequent UDP packets should be sent for relay by Svr.

 Socket must be an open socket descriptor of type SOCK_STREAM; Dst and Svr may be either IPv4 or IPv6 addresses.

Note that Socket cannot be used to send subsequent UDP packets (a second socket of type SOCK_DGRAM must be created).

Parameters

Socket Specifies the unique name of the socket.
Dst Specifies the external address of the target socket to which the SOCKSv5 client expects to send UDP packets.
DstLength Specifies the length of the address structure in Dst.
Svr Specifies the address of the SOCKSv5 server to use to request the association.
SvrLength Specifies the length of the address structure in Svr.

Return Values

Upon successful completion, the socks5udp_associate subroutine returns a value of 0 and overwrites Dst with the rendezvous address.

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

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

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

EBADF The Socket parameter is not valid.
ENOTSOCK The Socket parameter refers to a file, not a socket.
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.
EISCONN The socket is already connected.
ETIMEDOUT The establishment of a connection timed out before a connection was made.
ECONNREFUSED The attempt to connect was rejected.
ENETUNREACH No route to the network or host is present.
EADDRINUSE The specified address is already in use.
EFAULT The Address parameter is not in a writable part of the user address space.
EINPROGRESS The socket is marked as nonblocking. The connection cannot be immediately completed. The application program can select the socket for writing during the connection process.
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_ENOSERV No server found.

Examples

The following program fragment illustrates the use of the socks5udp_associate subroutine by a client to request an association on a server.

struct sockaddr_in svr;
struct sockaddr_in6 dst;
.
.
.
socks5udp_associate(s,(struct sockaddr*)&dst, sizeof(dst), (struct sockaddr *)&svr, sizeof(svr));

Implementation Specifics

The socks5udp_associate 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 socks5udp_sendto subroutine, socks5_getserv subroutine, /etc/socks5c.conf file, connect subroutine, accept subroutine, bind subroutine, getsockname subroutine, send subroutine, socket subroutine.

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


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]