gSocketBind {RGtk2} | R Documentation

## gSocketBind

### Description

When a socket is created it is attached to an address family, but it doesn't have an address in this family. `gSocketBind` assigns the address (sometimes called name) of the socket.

### Usage

    gSocketBind(object, address, allow.reuse, .errwarn = TRUE)

### Arguments

``object`` | a `GSocket`.
``address`` | a `GSocketAddress` specifying the local address.
``allow.reuse`` | whether to allow reusing this address
`.errwarn` | Whether to issue a warning on error or fail silently

### Details

It is generally required to bind to a local address before you can receive connections. (See `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

### Value

A list containing the following elements:

`retval` | [logical] `TRUE` on success, `FALSE` on error.
``error`` | `GError` for error reporting, or `NULL` to ignore.

### Author(s)

Derived by RGtkGen from GTK+ documentation

[Package RGtk2 version 2.20.36.3 Index]