![]() | ![]() | ![]() | GNetwork Library Manual | ![]() |
---|
GNetworkConnection — An abstract interface for connections.
struct GNetworkConnection; enum GNetworkConnectionStatus; enum GNetworkConnectionType; void gnetwork_connection_open (GNetworkConnection *connection); void gnetwork_connection_close (GNetworkConnection *connection); void gnetwork_connection_send (GNetworkConnection *connection, gconstpointer data, glong length); struct GNetworkConnectionIface; void gnetwork_connection_received (GNetworkConnection *connection, gconstpointer data, gulong length); void gnetwork_connection_error (GNetworkConnection *connection, const GError *error); void (*GNetworkConnectionFunc) (GNetworkConnection *connection); void (*GNetworkConnectionSendFunc) (GNetworkConnection *connection, gconstpointer data, gsize length);
GInterface +----GNetworkConnection
GNetworkConnection requires GObject.
GNetworkConnection is implemented by GNetworkTcpConnection.
"error" void user_function (GNetworkConnection *gnetworkconnection, GError *arg1, gpointer user_data); "received" void user_function (GNetworkConnection *gnetworkconnection, gpointer arg1, gulong arg2, gpointer user_data); "sent" void user_function (GNetworkConnection *gnetworkconnection, gpointer arg1, gulong arg2, gpointer user_data);
The GNetworkConnectionIface interface provides a standard set of methods and signals for connection objects.
struct GNetworkConnection;
An empty typedef for objects which implement the GNetworkConnectionIface interface.
typedef enum /* <prefix=GNETWORK_CONNECTION> */ { GNETWORK_CONNECTION_CLOSING, GNETWORK_CONNECTION_CLOSED, GNETWORK_CONNECTION_OPENING, GNETWORK_CONNECTION_OPEN } GNetworkConnectionStatus;
An enumeration of the possible connection states a GNetworkConnectionIface implementation may be in.
GNETWORK_CONNECTION_CLOSING | the connection is in the process of closing. |
GNETWORK_CONNECTION_CLOSED | the connection is closed. |
GNETWORK_CONNECTION_OPENING | the connection is in the process of opening. |
GNETWORK_CONNECTION_OPEN | the connection is open. |
typedef enum /* <prefix=GNETWORK_CONNECTION> */ { GNETWORK_CONNECTION_INVALID, GNETWORK_CONNECTION_CLIENT, GNETWORK_CONNECTION_SERVER } GNetworkConnectionType;
An enumeration of the types of connections that can exist.
GNETWORK_CONNECTION_INVALID | an invalid connection. |
GNETWORK_CONNECTION_CLIENT | a client connection. |
GNETWORK_CONNECTION_SERVER | a server connection. |
void gnetwork_connection_open (GNetworkConnection *connection);
Starts the connection process for connection.
connection : | the connection to open. |
Since 1.0
void gnetwork_connection_close (GNetworkConnection *connection);
Closes the connection in question.
connection : | the connection to close. |
Since 1.0
void gnetwork_connection_send (GNetworkConnection *connection, gconstpointer data, glong length);
Sends the data in data through connection. If length is less than one, data is assumed to be terminated by 0. This function will perform the necessary calculations for length. After calling the implementation's send function, the "send" signal will be emitted.
connection : | the connection to send through. |
data : | the data to send. |
length : | the length in bytes of data. |
Since 1.0
struct GNetworkConnectionIface { /* Signals */ void (*received) (GNetworkConnection * connection, gconstpointer data, gulong length); void (*sent) (GNetworkConnection * connection, gconstpointer data, gulong length); void (*error) (GNetworkConnection * connection, GError * error); /* Methods */ GNetworkConnectionFunc open; GNetworkConnectionFunc close; GNetworkConnectionSendFunc send; };
The interface structure for implementers.
void (*received) (GNetworkConnection * connection, gconstpointer data, gulong length) | the slot for the "received" signal. |
void (*sent) (GNetworkConnection * connection, gconstpointer data, gulong length) | the slot for the "sent" signal. |
void (*error) (GNetworkConnection * connection, GError * error) | the slot for the "error" signal. |
GNetworkConnectionFunc open | the open method. |
GNetworkConnectionFunc close | the close method. |
GNetworkConnectionSendFunc send | the send method. |
void gnetwork_connection_received (GNetworkConnection *connection, gconstpointer data, gulong length);
Emits the "received" signal for connection, using the values in data and length. Implementations of the GNetworkConnectionIface interface should use this function when data has been received.
connection : | the connection to use. |
data : | the data being recieved. |
length : | the length of data in bytes. |
Since 1.0
void gnetwork_connection_error (GNetworkConnection *connection, const GError *error);
Emits the "error" signal for connection, using error. Callers to this function should use their own error domains.
connection : | the connection to use. |
error : | the error structure. |
Since 1.0
void (*GNetworkConnectionFunc) (GNetworkConnection *connection);
A basic implementation function type.
connection : | the connection object. |
void (*GNetworkConnectionSendFunc) (GNetworkConnection *connection, gconstpointer data, gsize length);
An implementation function type used to send data.
connection : | the connection object. |
data : | the data to be sent. |
length : | the length of data in bytes. |
void user_function (GNetworkConnection *gnetworkconnection, GError *arg1, gpointer user_data);
This signal is emitted when an error occurs in the connection.
gnetworkconnection : | the object which received the signal. |
arg1 : | the error structure. |
user_data : | user data set when the signal handler was connected. |
void user_function (GNetworkConnection *gnetworkconnection, gpointer arg1, gulong arg2, gpointer user_data);
This signal is emitted when data has been received.
gnetworkconnection : | the object which received the signal. |
arg1 : | the data which was received. |
arg2 : | the size of data, in bytes. |
user_data : | user data set when the signal handler was connected. |
void user_function (GNetworkConnection *gnetworkconnection, gpointer arg1, gulong arg2, gpointer user_data);
This signal is emitted when data has been sent.
gnetworkconnection : | the object which received the signal. |
arg1 : | the data which was sent. |
arg2 : | the size of data, in bytes. |
user_data : | user data set when the signal handler was connected. |
<< Part III. API Reference | GNetworkTcpConnection >> |