EvdSocket

EvdSocket — EventDance's base socket class.

Synopsis

                    EvdSocket;
                    EvdSocketClass;
                    EvdSocketPrivate;
                    EvdSocketEvent;
void                (*EvdSocketNotifyConditionCallback) (EvdSocket *self,
                                                         GIOCondition condition,
                                                         gpointer user_data);
enum                EvdSocketState;
EvdSocket *         evd_socket_new                      (void);
GSocket *           evd_socket_get_socket               (EvdSocket *self);
GMainContext *      evd_socket_get_context              (EvdSocket *self);
GSocketFamily       evd_socket_get_family               (EvdSocket *self);
EvdSocketState      evd_socket_get_status               (EvdSocket *self);
gint                evd_socket_get_priority             (EvdSocket *self);
void                evd_socket_set_priority             (EvdSocket *self,
                                                         gint priority);
gboolean            evd_socket_close                    (EvdSocket *self,
                                                         GError **error);
GSocketAddress *    evd_socket_get_remote_address       (EvdSocket *self,
                                                         GError **error);
GSocketAddress *    evd_socket_get_local_address        (EvdSocket *self,
                                                         GError **error);
gboolean            evd_socket_shutdown                 (EvdSocket *self,
                                                         gboolean shutdown_read,
                                                         gboolean shutdown_write,
                                                         GError **error);
gboolean            evd_socket_watch_condition          (EvdSocket *self,
                                                         GIOCondition cond,
                                                         GError **error);
GIOCondition        evd_socket_get_condition            (EvdSocket *self);
void                evd_socket_set_notify_condition_callback
                                                        (EvdSocket *self,
                                                         EvdSocketNotifyConditionCallback callback,
                                                         gpointer user_data);
gboolean            evd_socket_bind_addr                (EvdSocket *self,
                                                         GSocketAddress *address,
                                                         gboolean allow_reuse,
                                                         GError **error);
void                evd_socket_bind_async               (EvdSocket *self,
                                                         const gchar *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            evd_socket_bind_finish              (EvdSocket *self,
                                                         GAsyncResult *result,
                                                         GError **error);
gboolean            evd_socket_listen_addr              (EvdSocket *self,
                                                         GSocketAddress *address,
                                                         GError **error);
void                evd_socket_listen_async             (EvdSocket *self,
                                                         const gchar *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            evd_socket_listen_finish            (EvdSocket *self,
                                                         GAsyncResult *result,
                                                         GError **error);
void                evd_socket_connect_async            (EvdSocket *self,
                                                         const gchar *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
void                evd_socket_connect_async_addr       (EvdSocket *self,
                                                         GSocketAddress *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GIOStream *         evd_socket_connect_finish           (EvdSocket *self,
                                                         GAsyncResult *result,
                                                         GError **error);

Object Hierarchy

  GObject
   +----EvdSocket

Properties

  "family"                   GSocketFamily         : Read / Write
  "io-stream-type"           GType*                : Read / Write
  "priority"                 gint                  : Read / Write
  "protocol"                 GSocketProtocol       : Read / Write
  "socket"                   GSocket*              : Read
  "status"                   guint                 : Read
  "type"                     GSocketType           : Read / Write

Signals

  "close"                                          : Run Last / Action
  "error"                                          : Run Last / Action
  "new-connection"                                 : Run Last / Action
  "state-changed"                                  : Run Last / Action

Description

EvdSocket sockets are Berkeley-style sockets optmized for performance and scalability under high-concurrency scenarios.

Details

EvdSocket

typedef struct _EvdSocket EvdSocket;


EvdSocketClass

typedef struct {
  GObjectClass parent_class;

  /* virtual methods */
  gboolean (* handle_condition) (EvdSocket *self, GIOCondition condition);
  gboolean (* cleanup)          (EvdSocket *self, GError **error);

  /* signal prototypes */
  void (* error)          (EvdSocket *self,
                           guint32    error_domain,
                           gint       error_code,
                           gchar     *error_message,
                           gpointer   user_data);
  void (* state_changed)  (EvdSocket      *self,
                           EvdSocketState  new_state,
                           EvdSocketState  old_state);
  void (* close)          (EvdSocket *self);
  void (* new_connection) (EvdSocket *self,
                           GIOStream *socket,
                           gpointer   user_data);
} EvdSocketClass;


EvdSocketPrivate

typedef struct _EvdSocketPrivate EvdSocketPrivate;


EvdSocketEvent

typedef struct _EvdSocketEvent EvdSocketEvent;


EvdSocketNotifyConditionCallback ()

void                (*EvdSocketNotifyConditionCallback) (EvdSocket *self,
                                                         GIOCondition condition,
                                                         gpointer user_data);

self :

condition :

user_data :


enum EvdSocketState

typedef enum
{
  EVD_SOCKET_STATE_CLOSED,
  EVD_SOCKET_STATE_CONNECTING,
  EVD_SOCKET_STATE_CONNECTED,
  EVD_SOCKET_STATE_RESOLVING,
  EVD_SOCKET_STATE_BOUND,
  EVD_SOCKET_STATE_LISTENING,
  EVD_SOCKET_STATE_TLS_HANDSHAKING,
  EVD_SOCKET_STATE_CLOSING
} EvdSocketState;


evd_socket_new ()

EvdSocket *         evd_socket_new                      (void);

Returns :


evd_socket_get_socket ()

GSocket *           evd_socket_get_socket               (EvdSocket *self);

self :

Returns :


evd_socket_get_context ()

GMainContext *      evd_socket_get_context              (EvdSocket *self);

self :

Returns :


evd_socket_get_family ()

GSocketFamily       evd_socket_get_family               (EvdSocket *self);

self :

Returns :


evd_socket_get_status ()

EvdSocketState      evd_socket_get_status               (EvdSocket *self);

self :

Returns :


evd_socket_get_priority ()

gint                evd_socket_get_priority             (EvdSocket *self);

self :

Returns :


evd_socket_set_priority ()

void                evd_socket_set_priority             (EvdSocket *self,
                                                         gint priority);

self :

priority :


evd_socket_close ()

gboolean            evd_socket_close                    (EvdSocket *self,
                                                         GError **error);

self :

error :

Returns :


evd_socket_get_remote_address ()

GSocketAddress *    evd_socket_get_remote_address       (EvdSocket *self,
                                                         GError **error);

self :

error :

Returns :


evd_socket_get_local_address ()

GSocketAddress *    evd_socket_get_local_address        (EvdSocket *self,
                                                         GError **error);

self :

error :

Returns :


evd_socket_shutdown ()

gboolean            evd_socket_shutdown                 (EvdSocket *self,
                                                         gboolean shutdown_read,
                                                         gboolean shutdown_write,
                                                         GError **error);

self :

shutdown_read :

shutdown_write :

error :

Returns :


evd_socket_watch_condition ()

gboolean            evd_socket_watch_condition          (EvdSocket *self,
                                                         GIOCondition cond,
                                                         GError **error);

self :

cond :

error :

Returns :


evd_socket_get_condition ()

GIOCondition        evd_socket_get_condition            (EvdSocket *self);

self :

Returns :


evd_socket_set_notify_condition_callback ()

void                evd_socket_set_notify_condition_callback
                                                        (EvdSocket *self,
                                                         EvdSocketNotifyConditionCallback callback,
                                                         gpointer user_data);

self :

callback :

. [allow-none]

user_data :

. [allow-none]

evd_socket_bind_addr ()

gboolean            evd_socket_bind_addr                (EvdSocket *self,
                                                         GSocketAddress *address,
                                                         gboolean allow_reuse,
                                                         GError **error);

self :

address :

allow_reuse :

error :

Returns :


evd_socket_bind_async ()

void                evd_socket_bind_async               (EvdSocket *self,
                                                         const gchar *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

self :

address :

cancellable :

callback :

user_data :


evd_socket_bind_finish ()

gboolean            evd_socket_bind_finish              (EvdSocket *self,
                                                         GAsyncResult *result,
                                                         GError **error);

self :

result :

error :

Returns :


evd_socket_listen_addr ()

gboolean            evd_socket_listen_addr              (EvdSocket *self,
                                                         GSocketAddress *address,
                                                         GError **error);

self :

address :

error :

Returns :


evd_socket_listen_async ()

void                evd_socket_listen_async             (EvdSocket *self,
                                                         const gchar *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

self :

address :

cancellable :

callback :

user_data :


evd_socket_listen_finish ()

gboolean            evd_socket_listen_finish            (EvdSocket *self,
                                                         GAsyncResult *result,
                                                         GError **error);

self :

result :

error :

Returns :


evd_socket_connect_async ()

void                evd_socket_connect_async            (EvdSocket *self,
                                                         const gchar *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

self :

address :

cancellable :

callback :

user_data :


evd_socket_connect_async_addr ()

void                evd_socket_connect_async_addr       (EvdSocket *self,
                                                         GSocketAddress *address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

self :

address :

cancellable :

callback :

user_data :


evd_socket_connect_finish ()

GIOStream *         evd_socket_connect_finish           (EvdSocket *self,
                                                         GAsyncResult *result,
                                                         GError **error);

self :

result :

error :

Returns :

Property Details

The "family" property

  "family"                   GSocketFamily         : Read / Write

The sockets address family.

Default value: G_SOCKET_FAMILY_INVALID


The "io-stream-type" property

  "io-stream-type"           GType*                : Read / Write

The GType of the socket's IO stream returned by #evd_socket_get_io_stream.


The "priority" property

  "priority"                 gint                  : Read / Write

The priority of the socket when dispatching its events in the loop.

Allowed values: [-100,300]

Default value: 0


The "protocol" property

  "protocol"                 GSocketProtocol       : Read / Write

The id of the protocol to use, or -1 for unknown.

Default value: G_SOCKET_PROTOCOL_UNKNOWN


The "socket" property

  "socket"                   GSocket*              : Read

The underlaying socket.


The "status" property

  "status"                   guint                 : Read

The current status of the socket (closed, connected, listening, etc).

Allowed values: <= 5

Default value: 0


The "type" property

  "type"                     GSocketType           : Read / Write

The sockets type.

Default value: G_SOCKET_TYPE_INVALID

Signal Details

The "close" signal

void                user_function                      (EvdSocket *evdsocket,
                                                        gpointer   user_data)      : Run Last / Action

evdsocket :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "error" signal

void                user_function                      (EvdSocket *evdsocket,
                                                        guint      arg1,
                                                        gint       arg2,
                                                        gchar     *arg3,
                                                        gpointer   user_data)      : Run Last / Action

evdsocket :

the object which received the signal.

arg1 :

arg2 :

arg3 :

user_data :

user data set when the signal handler was connected.

The "new-connection" signal

void                user_function                      (EvdSocket *evdsocket,
                                                        GIOStream *arg1,
                                                        gpointer   user_data)      : Run Last / Action

evdsocket :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "state-changed" signal

void                user_function                      (EvdSocket *evdsocket,
                                                        guint      arg1,
                                                        guint      arg2,
                                                        gpointer   user_data)      : Run Last / Action

evdsocket :

the object which received the signal.

arg1 :

arg2 :

user_data :

user data set when the signal handler was connected.