## InfdTcpServer InfdTcpServer |

## Functions

gboolean | infd_tcp_server_bind ()
gboolean | infd_tcp_server_open ()
void | infd_tcp_server_close ()
void | infd_tcp_server_set_keepalive ()
const InfKeepalive * | infd_tcp_server_get_keepalive ()

## Properties

InfIo * | io | Read / Write / Construct Only
InfKeepalive * | keepalive | Read / Write
InfIpAddress * | local-address | Read / Write
guint | local-port | Read / Write
InfdTcpServerStatus | status | Read

## Signals

void | error | Run Last
void | new-connection | Run Last

## Types and Values

enum | InfdTcpServerStatus
struct | InfdTcpServer
struct | InfdTcpServerClass

## Object Hierarchy

        GEnum
        ╰── InfdTcpServerStatus
        GObject
        ╰── InfdTcpServer

## Description

## Functions

### infd_tcp_server_bind ()

    gboolean
    infd_tcp_server_bind (InfdTcpServer *server,
                          GError **error);

Binds the server to the address and port given by the “local-address” and “local-port” properties. If the former is `NULL`, it will bind on all interfaces on IPv4. If the latter is 0, a random available port will be assigned. If the function fails, `FALSE` is returned and an error is set.

`server` must be in `INFD_TCP_SERVER_CLOSED` state for this function to be called.

#### Parameters

server | A InfdTcpServer. |
error | Location to store error information, if any. |

#### Returns

`TRUE` on success, or `FALSE` if an error occured.

### infd_tcp_server_open ()

    gboolean
    infd_tcp_server_open (InfdTcpServer *server,
                          GError **error);

Attempts to open `server` . This means binding its local address and port if not already (see `infd_tcp_server_bind()`) and accepting incoming connections.

`server` needs to be in `INFD_TCP_SERVER_CLOSED` or `INFD_TCP_SERVER_BOUND` status for this function to be called. If `server` 's status is `INFD_TCP_SERVER_CLOSED`, then `infd_tcp_server_bind()` is called before actually opening the server.

#### Parameters

server | A InfdTcpServer. |
error | Location to store error information. |

#### Returns

`TRUE` on success, or `FALSE` if an error occured.

### infd_tcp_server_close ()

    void
    infd_tcp_server_close (InfdTcpServer *server);

Closes a TCP server that is open or bound.

#### Parameters

server | A InfdTcpServer. |

### infd_tcp_server_set_keepalive ()

    void
    infd_tcp_server_set_keepalive (InfdTcpServer *server,
                                   const InfKeepalive *keepalive);

Sets the keepalive settings for new connections accepted by the server.

#### Parameters

server | A InfdTcpServer. |
keepalive | The keepalive settings for accepted connections. |

### infd_tcp_server_get_keepalive ()

    const InfKeepalive *
    infd_tcp_server_get_keepalive (InfdTcpServer *server);

Obtains the current keepalive settings for accepted connections.

#### Parameters

server | A InfdTcpServer. |

#### Returns

A InfKeepalive representing the keepalive configuration for accepted connections, owned by `server` .

## Types and Values

### enum InfdTcpServerStatus

#### Members

INFD_TCP_SERVER_CLOSED |  |
INFD_TCP_SERVER_BOUND |  |
INFD_TCP_SERVER_OPEN |  |

### struct InfdTcpServer

    struct InfdTcpServer;

### struct InfdTcpServerClass

    struct InfdTcpServerClass {
      GObjectClass parent_class;

      /* Signals */
      void (*new_connection)(InfdTcpServer* server,
                             InfTcpConnection* connection);

      void (*error)(InfdTcpServer* server,
                    GError* error);
    };

## Property Details

### The `“io”` property

      “io”                       InfIo *

I/O handler.

Flags: Read / Write / Construct Only

### The `“keepalive”` property

      “keepalive”                InfKeepalive *

Keepalive settings for accepted connections.

Flags: Read / Write

### The `“local-address”` property

      “local-address”            InfIpAddress *

Address to bind to.

Flags: Read / Write

### The `“local-port”` property

      “local-port”               guint

Port to bind to.

Flags: Read / Write

Allowed values: <= 65535

Default value: 0

### The `“status”` property

      “status”                   InfdTcpServerStatus

Status of the TCP server.

Flags: Read

Default value: INFD_TCP_SERVER_CLOSED

## Signal Details

### The `“error”` signal

    void
    user_function (InfdTcpServer *infdtcpserver,
                   GError        *arg1,
                   gpointer       user_data)

#### Parameters

infdtcpserver | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“new-connection”` signal

    void
    user_function (InfdTcpServer    *infdtcpserver,
                   InfTcpConnection *arg1,
                   gpointer          user_data)

#### Parameters

infdtcpserver | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last