## Datagram I/O

Datagram I/O — base class for datagram I/O classes

## Synopsis

                        GskPacketQueueClass;
                        GskPacketQueue;
    gboolean            gsk_packet_queue_bind               (GskPacketQueue *queue,
                                                             GskSocketAddress *address,
                                                             GError **error);
    GskPacket *         gsk_packet_queue_read               (GskPacketQueue *queue,
                                                             gboolean save_address,
                                                             GError **error);
    gboolean            gsk_packet_queue_write              (GskPacketQueue *queue,
                                                             GskPacket *out,
                                                             GError **error);
    #define             gsk_packet_queue_get_allow_address  (queue)
    #define             gsk_packet_queue_get_allow_no_address(queue)
    #define             gsk_packet_queue_get_misses_packets (queue)
    #define             gsk_packet_queue_get_is_readable    (queue)
    #define             gsk_packet_queue_get_is_writable    (queue)
    #define             gsk_packet_queue_peek_bound_address (queue)
    #define             gsk_packet_queue_mark_allow_address (queue)
    #define             gsk_packet_queue_mark_allow_no_address(queue)
    #define             gsk_packet_queue_mark_misses_packets(queue)
    #define             gsk_packet_queue_mark_is_readable   (queue)
    #define             gsk_packet_queue_mark_is_writable   (queue)
    #define             gsk_packet_queue_clear_allow_address(queue)
    #define             gsk_packet_queue_clear_allow_no_address(queue)
    #define             gsk_packet_queue_clear_misses_packets(queue)
    #define             gsk_packet_queue_clear_is_readable  (queue)
    #define             gsk_packet_queue_clear_is_writable  (queue)
    void                gsk_packet_queue_set_bound_addresss (GskPacketQueue *queue,
                                                             GskSocketAddress *address);

## Object Hierarchy

      GObject
       +----GskIO
             +----GskPacketQueue
                   +----GskPacketQueueFd

## Description

Datagram I/O means binary packets of data are the transmission unit. You can bind to an address in the right family, and read and write packets. Unless the packet_queue is bound, it is unlikely to ever be readable.

## Details

### GskPacketQueueClass

    typedef struct {
      GskIOClass io_class;
      gboolean   (*bind)  (GskPacketQueue    *queue,
    		       GskSocketAddress  *addr,
    		       GError           **error);
      GskPacket *(*read)  (GskPacketQueue    *queue,
    		       gboolean           save_address,
    		       GError           **error);
      gboolean   (*write) (GskPacketQueue    *queue,
    		       GskPacket         *out,
    		       GError           **error);
    } GskPacketQueueClass;

Base class for an object which can input and output packets.

GskIOClass `io_class`; | parent class.
`bind` () | bind to a particular socket-address.
`read` () | read an incoming packet.
`write` () | write an outgoing packet.

### GskPacketQueue

    typedef struct _GskPacketQueue GskPacketQueue;

Abstract instance which can read and write packets.

### gsk_packet_queue_bind ()

    gboolean            gsk_packet_queue_bind               (GskPacketQueue *queue,
                                                             GskSocketAddress *address,
                                                             GError **error);

Bind a packet queue to receive on a particular address.

`queue` : | the packet queue to bind to a particular address.
`address` : | the address to receive packets from.
`error` : | optional error return value.
Returns : | whether the bind call succeeded.

### gsk_packet_queue_read ()

    GskPacket *         gsk_packet_queue_read               (GskPacketQueue *queue,
                                                             gboolean save_address,
                                                             GError **error);

Read a packet from the queue, optionally tracking whence it came.

`queue` : | to try to read a packet from
`save_address` : | whether to create a remote address indication.
`error` : | optional error return value.
Returns : | a new packet, or NULL on error or if no packet was available.

### gsk_packet_queue_write ()

    gboolean            gsk_packet_queue_write              (GskPacketQueue *queue,
                                                             GskPacket *out,
                                                             GError **error);

Try and write a packet to the queue. If the packet has no address, then the packet-queue must allow_no_address. If the packet has an address, then the packet-queue must allow_address.

`queue` : | to try to write a packet to
`out` : | outgoing packet.
`error` : | optional error return value.
Returns : | whether the write succeeded.

### gsk_packet_queue_get_allow_address()

    #define             gsk_packet_queue_get_allow_address(queue)

Determine whether packets with remote addresses may be written to this packet queue.

`queue` : | the packet-queue to query.

### gsk_packet_queue_get_allow_no_address()

    #define             gsk_packet_queue_get_allow_no_address(queue)

Determine whether packets without a remote address may be written to this packet queue.

`queue` : | the packet-queue to query.

### gsk_packet_queue_get_misses_packets()

    #define             gsk_packet_queue_get_misses_packets(queue)

Determine whether the packet-queue drops incoming packets.

`queue` : | the packet-queue to query.

### gsk_packet_queue_get_is_readable()

    #define             gsk_packet_queue_get_is_readable(queue)

Determine whether the packet-queue may have incoming packets.

`queue` : | the packet-queue to query.

### gsk_packet_queue_get_is_writable()

    #define             gsk_packet_queue_get_is_writable(queue)

Determine whether the packet-queue may have packets written to it.

`queue` : | the packet-queue to query.

### gsk_packet_queue_peek_bound_address()

    #define             gsk_packet_queue_peek_bound_address(queue)

Get the address this queue is bound to, or NULL.

`queue` : | the packet-queue to query.

### gsk_packet_queue_mark_allow_address()

    #define             gsk_packet_queue_mark_allow_address(queue)

Indicate that this packet-queue can accept outgoing packets which have an address.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_mark_allow_no_address()

    #define             gsk_packet_queue_mark_allow_no_address(queue)

Indicate that this packet-queue can accept outgoing packets which have an no address.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_mark_misses_packets()

    #define             gsk_packet_queue_mark_misses_packets(queue)

Indicate that this packet-queue may drop incoming packets.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_mark_is_readable()

    #define             gsk_packet_queue_mark_is_readable(queue)

Indicate that this packet-queue may be read from.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_mark_is_writable()

    #define             gsk_packet_queue_mark_is_writable(queue)

Indicate that this packet-queue may be written to.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_clear_allow_address()

    #define             gsk_packet_queue_clear_allow_address(queue)

Indicate that this packet-queue cannot accept outgoing packets which have an address.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_clear_allow_no_address()

    #define             gsk_packet_queue_clear_allow_no_address(queue)

Indicate that this packet-queue cannot accept outgoing packets which have no address.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_clear_misses_packets()

    #define             gsk_packet_queue_clear_misses_packets(queue)

Indicate that this packet-queue will not drop incoming packets.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_clear_is_readable()

    #define             gsk_packet_queue_clear_is_readable(queue)

Indicate that this packet-queue may not be read from.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_clear_is_writable()

    #define             gsk_packet_queue_clear_is_writable(queue)

Indicate that this packet-queue may not be written to.

This should only be used by derived classes.

`queue` : | the packet-queue to affect.

### gsk_packet_queue_set_bound_addresss ()

    void                gsk_packet_queue_set_bound_addresss (GskPacketQueue *queue,
                                                             GskSocketAddress *address);

Set the bound_address member of the packet-queue safely.

This should only be called by implementations which automatically bind to certain addresses.

`queue` : | queue to mark
`address` : | address to which the queue has been bound.

## See Also

GskIO