InfTcpConnection

InfTcpConnection

Synopsis

enum                InfTcpConnectionStatus;
                    InfTcpConnection;
                    InfTcpConnectionClass;
InfTcpConnection *  inf_tcp_connection_new              (InfIo *io,
                                                         InfIpAddress *remote_addr,
                                                         guint remote_port);
InfTcpConnection *  inf_tcp_connection_new_and_open     (InfIo *io,
                                                         InfIpAddress *remote_addr,
                                                         guint remote_port,
                                                         GError **error);
gboolean            inf_tcp_connection_open             (InfTcpConnection *connection,
                                                         GError **error);
void                inf_tcp_connection_close            (InfTcpConnection *connection);
void                inf_tcp_connection_send             (InfTcpConnection *connection,
                                                         gconstpointer data,
                                                         guint len);
InfIpAddress *      inf_tcp_connection_get_remote_address
                                                        (InfTcpConnection *connection);
guint               inf_tcp_connection_get_remote_port  (InfTcpConnection *connection);

Object Hierarchy

  GObject
   +----InfTcpConnection

Properties

  "device-index"             guint                 : Read / Write
  "device-name"              gchar*                : Read / Write
  "io"                       InfIo*                : Read / Write / Construct Only
  "local-address"            InfIpAddress*         : Read
  "local-port"               guint                 : Read
  "remote-address"           InfIpAddress*         : Read / Write
  "remote-port"              guint                 : Read / Write
  "status"                   InfTcpConnectionStatus  : Read

Signals

  "error"                                          : Run Last
  "received"                                       : Run Last
  "sent"                                           : Run Last

Description

Details

enum InfTcpConnectionStatus

typedef enum _InfTcpConnectionStatus {
  INF_TCP_CONNECTION_CONNECTING,
  INF_TCP_CONNECTION_CONNECTED,
  INF_TCP_CONNECTION_CLOSED
} InfTcpConnectionStatus;


InfTcpConnection

typedef struct _InfTcpConnection InfTcpConnection;


InfTcpConnectionClass

typedef struct {
  GObjectClass parent_class;

  /* Signals */
  void (*sent)(InfTcpConnection* connection,
               gconstpointer data,
               guint len);

  void (*received)(InfTcpConnection* connection,
                   gconstpointer data,
                   guint len);

  void (*error)(InfTcpConnection* connection,
                GError* error);
} InfTcpConnectionClass;


inf_tcp_connection_new ()

InfTcpConnection *  inf_tcp_connection_new              (InfIo *io,
                                                         InfIpAddress *remote_addr,
                                                         guint remote_port);

Creates a new InfTcpConnection. The arguments are stored as properties for an eventual inf_tcp_connection_open() call, this function itself does not establish a connection.

io :

A InfIo object used to watch for activity.

remote_addr :

The address to eventually connect to.

remote_port :

The port to eventually connect to.

Returns :

A new InfTcpConnection. Free with g_object_unref().

inf_tcp_connection_new_and_open ()

InfTcpConnection *  inf_tcp_connection_new_and_open     (InfIo *io,
                                                         InfIpAddress *remote_addr,
                                                         guint remote_port,
                                                         GError **error);

Creates a new InfTcpConnection and connects it to the given TCP endpoint. Like inf_tcp_connection_new, but calls inf_tcp_connection_open().

io :

A InfIo object used to watch for activity.

remote_addr :

The address to connect to.

remote_port :

The port to connect to.

error :

Location to store error information.

Returns :

A new InfTcpConnection, or NULL on error. Free with g_object_unref().

inf_tcp_connection_open ()

gboolean            inf_tcp_connection_open             (InfTcpConnection *connection,
                                                         GError **error);

Attempts to open connection. Make sure to have set the "remote-address" and "remote-port" property before calling this function. If an error occurs, the function returns FALSE and error is set. Note however that the connection might not be fully open when the function returns (check the "status" property if you need to know). If an asynchronous error occurs while the connection is being opened, the "error" signal is emitted.

connection :

A InfTcpConnection.

error :

Location to store error information.

Returns :

FALSE if an error occured and TRUE otherwise.

inf_tcp_connection_close ()

void                inf_tcp_connection_close            (InfTcpConnection *connection);

Closes a TCP connection that is either open or currently connecting.

connection :

A InfTcpConnection.

inf_tcp_connection_send ()

void                inf_tcp_connection_send             (InfTcpConnection *connection,
                                                         gconstpointer data,
                                                         guint len);

Sends data through the TCP connection. The data is not sent immediately, but enqueued to a buffer and will be sent as soon as kernel space becomes available. The "sent" signal will be emitted when data has really been sent.

connection :

A InfTcpConnection with status INF_TCP_CONNECTION_CONNECTED.

data :

The data to send.

len :

Number of bytes to send.

inf_tcp_connection_get_remote_address ()

InfIpAddress *      inf_tcp_connection_get_remote_address
                                                        (InfTcpConnection *connection);

Returns the IP address of the remote site.

connection :

A InfTcpConnection.

Returns :

A InfIpAddress owned by connection. You do not need to free it, but need to make your own copy if you want to keep it longer than connection's lifetime.

inf_tcp_connection_get_remote_port ()

guint               inf_tcp_connection_get_remote_port  (InfTcpConnection *connection);

Returns the port of the remote site to which connection is (or was) connected or connecting.

connection :

A InfTcpConnection.

Returns :

The port of the remote site.

Property Details

The "device-index" property

  "device-index"             guint                 : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use : Read / Write

The index of the device to use