gSocketBind
assigns the
address (sometimes called name) of the socket.gSocketBind(object, address, allow.reuse, .errwarn = TRUE)
object
GSocket
.address
GSocketAddress
specifying the local address.allow.reuse
TRUE
on success, FALSE
on error.error
GError
for error reporting, or NULL
to ignore.gSocketListen
and gSocketAccept
).
In certain situations, you may also want to bind a socket that will be
used to initiate connections, though this is not normally required.
allow.reuse
should be TRUE
for server sockets (sockets that you will
eventually call gSocketAccept
on), and FALSE
for client sockets.
(Specifically, if it is TRUE
, then gSocketBind
will set the
SO_REUSEADDR
flag on the socket, allowing it to bind address
even if
that address was previously used by another socket that has not yet been
fully cleaned-up by the kernel. Failing to set this flag on a server
socket may cause the bind call to return G_IO_ERROR_ADDRESS_IN_USE
if
the server program is stopped and then immediately restarted.)
Since 2.22