%SS_BIND

Bind a name to an unbound socket (IPv4)

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
status = %SS_BIND(socket, in_port, in_addr)

Return value

status

Returns SS_SUCCESS (0) or one of the errors in Error codes returned by %SS_BIND below. (n)

Arguments

socket

A descriptor of an open socket created by %SS_SOCKET. (i4)

in_port

The local internet port to associate with the socket or 0 (zero). (i4)

in_addr

The local IPv4 address to associate with the socket or SS_INADDR_ANY. (i4)

Discussion

%SS_BIND binds a name to an unbound socket. In_port and in_addr are used to name it.

If in_port is zero, a random port greater than 1023 is assigned. (Clients typically specify zero, while servers specify well-known ports.)

If in_addr is SS_INADDR_ANY, rather than associating a specific IP address with the socket, any appropriate network interface is used for sending or receiving data. This simplifies programming in the presence of multihomed hosts.

Note

A connection-oriented client does not need to call %SS_BIND for a socket if it wishes to use a random port and any address, because %SS_CONNECT automatically performs this type of bind.

Error codes returned by %SS_BIND

See the Socket Errors table for additional information about these errors.

SS_EACCES

SS_EADDRINUSE

SS_EADDRNOTAVAIL

SS_EBADF

SS_EINVAL

SS_EISCONN

SS_ENETDOWN

SS_ENOBUFS

SS_ENOMEM

SS_ENOTSOCK

SS_EUNKNOWN

SS_NOTINITIALISED