%SS2_BIND

Bind a name to an unbound socket (IPv6)

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

Return value

status

Returns SS_SUCCESS (0) or one of the errors in Error codes returned by %SS2_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_addr6

The local IPv6 address to associate with the socket. ([#]byte)

Discussion

%SS2_BIND binds a name to an unbound socket. In_port and in_addr6 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.)

Note

Unlike %SS_BIND, the in_addr6 argument in %SS2_BIND does not support the define IN_ADDR_ANY. This define allows any suitable network interface to be used for sending or receiving data, which can simplify programming in the presence of multihomed hosts. In synsock.def, IN_ADDR_ANY is mapped to 0. To achieve the same effect with %SS2_BIND, you will need to programmatically set each element of the byte array to 0. For example:

record
   addr   ,[#]byte
   val    ,i4
proc
   addr = new byte[16] 
   for val from 1 thru 16 
     addr[val] = 0

There is also an example of this in the IPv6 example.

Note

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

Error codes returned by %SS2_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