![]() |
![]() |
![]() |
libinfinity-0.3 Reference Manual | ![]() |
---|---|---|---|---|
enum InfTcpConnectionStatus; InfTcpConnection; InfTcpConnectionClass; 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);
"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
typedef enum _InfTcpConnectionStatus { INF_TCP_CONNECTION_CONNECTING, INF_TCP_CONNECTION_CONNECTED, INF_TCP_CONNECTION_CLOSED } InfTcpConnectionStatus;
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;
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.
|
A InfTcpConnection. |
|
Location to store error information. |
Returns : |
FALSE if an error occured and TRUE otherwise.
|
void inf_tcp_connection_close (InfTcpConnection *connection);
Closes a TCP connection that is either open or currently connecting.
|
A InfTcpConnection. |
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.
|
A InfTcpConnection with status INF_TCP_CONNECTION_CONNECTED .
|
|
The data to send. |
|
Number of bytes to send. |
InfIpAddress* inf_tcp_connection_get_remote_address (InfTcpConnection *connection);
Returns the IP address of the remote site.
|
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.
|
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.
|
A InfTcpConnection. |
Returns : |
The port of the remote site. |
"device-index"
property"device-index" guint : Read / Write
The index of the device to use for the connection.
Default value: 0
"device-name"
property"device-name" gchar* : Read / Write
The name of the device to use for the connection, such as `eth0'.
Default value: NULL
"local-address"
property"local-address" InfIpAddress* : Read
The local address of the connection.
"local-port"
property"local-port" guint : Read
The local port of the connection.
Allowed values: <= 65535
Default value: 0
"remote-port"
property"remote-port" guint : Read / Write
Port to connect to.
Allowed values: <= 65535
Default value: 0
"status"
property"status" InfTcpConnectionStatus : Read
Status of the TCP connection.
Default value: INF_TCP_CONNECTION_CLOSED
"error"
signalvoid user_function (InfTcpConnection *connection, gpointer error, gpointer user_data) : Run Last
|
The erroneous InfTcpConnection |
|
A pointer to a GError object with details on the error |
|
user data set when the signal handler was connected. |
"received"
signalvoid user_function (InfTcpConnection *connection, gpointer data, guint length, gpointer user_data) : Run Last
|
The InfTcpConnection through which the data has been received |
|
A gpointer refering to the data that has been received |
|
A guint holding the number of bytes that has been received |
|
user data set when the signal handler was connected. |
"sent"
signalvoid user_function (InfTcpConnection *connection, gpointer data, guint length, gpointer user_data) : Run Last
|
The InfTcpConnection through which the data has been sent |
|
A gpointer refering to the data that has been sent |
|
A guint holding the number of bytes that has been sent |
|
user data set when the signal handler was connected. |