GNetworkConnection

GNetworkConnection — An abstract interface for connections.

Synopsis




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);

Object Hierarchy


  GInterface
   +----GNetworkConnection

Prerequisites

GNetworkConnection requires GObject.

Known Implementations

GNetworkConnection is implemented by GNetworkTcpConnection.

Signal Prototypes


"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);

Description

The GNetworkConnectionIface interface provides a standard set of methods and signals for connection objects.

Details

struct GNetworkConnection

struct GNetworkConnection;

An empty typedef for objects which implement the GNetworkConnectionIface interface.


enum GNetworkConnectionStatus

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_CLOSINGthe connection is in the process of closing.
GNETWORK_CONNECTION_CLOSEDthe connection is closed.
GNETWORK_CONNECTION_OPENINGthe connection is in the process of opening.
GNETWORK_CONNECTION_OPENthe connection is open.

enum GNetworkConnectionType

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_INVALIDan invalid connection.
GNETWORK_CONNECTION_CLIENTa client connection.
GNETWORK_CONNECTION_SERVERa server connection.

gnetwork_connection_open ()

void        gnetwork_connection_open        (GNetworkConnection *connection);

Starts the connection process for connection.

connection : the connection to open.

Since 1.0


gnetwork_connection_close ()

void        gnetwork_connection_close       (GNetworkConnection *connection);

Closes the connection in question.

connection : the connection to close.

Since 1.0


gnetwork_connection_send ()

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

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 openthe open method.
GNetworkConnectionFunc closethe close method.
GNetworkConnectionSendFunc sendthe send method.

gnetwork_connection_received ()

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


gnetwork_connection_error ()

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


GNetworkConnectionFunc ()

void        (*GNetworkConnectionFunc)       (GNetworkConnection *connection);

A basic implementation function type.

connection :the connection object.

GNetworkConnectionSendFunc ()

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.

Signals

The "error" signal

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.

The "received" signal

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.

The "sent" signal

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.