CamelTcpStream
3
CAMEL Library

# CamelTcpStream

## Synopsis

    struct              CamelTcpStream;
    enum                CamelSockOpt;
    typedef             CamelLinger;
                        CamelSockOptData;
    int                 camel_tcp_stream_connect            (CamelTcpStream *stream,
                                                             struct addrinfo *host);
    int                 camel_tcp_stream_getsockopt         (CamelTcpStream *stream,
                                                             CamelSockOptData *data);
    int                 camel_tcp_stream_setsockopt         (CamelTcpStream *stream,
                                                             const CamelSockOptData *data);

## Description

## Details

### struct CamelTcpStream

    struct CamelTcpStream {
    	CamelStream parent_object;
    };

### enum CamelSockOpt

    typedef enum {
    	CAMEL_SOCKOPT_NONBLOCKING,     /* nonblocking io */
    	CAMEL_SOCKOPT_LINGER,          /* linger on close if data present */
    	CAMEL_SOCKOPT_REUSEADDR,       /* allow local address reuse */
    	CAMEL_SOCKOPT_KEEPALIVE,       /* keep connections alive */
    	CAMEL_SOCKOPT_RECVBUFFERSIZE,  /* receive buffer size */
    	CAMEL_SOCKOPT_SENDBUFFERSIZE,  /* send buffer size */

    	CAMEL_SOCKOPT_IPTIMETOLIVE,    /* time to live */
    	CAMEL_SOCKOPT_IPTYPEOFSERVICE, /* type of service and precedence */

    	CAMEL_SOCKOPT_ADDMEMBER,       /* add an IP group membership */
    	CAMEL_SOCKOPT_DROPMEMBER,      /* drop an IP group membership */
    	CAMEL_SOCKOPT_MCASTINTERFACE,  /* multicast interface address */
    	CAMEL_SOCKOPT_MCASTTIMETOLIVE, /* multicast timetolive */
    	CAMEL_SOCKOPT_MCASTLOOPBACK,   /* multicast loopback */

    	CAMEL_SOCKOPT_NODELAY,         /* don't delay send to coalesce packets */
    	CAMEL_SOCKOPT_MAXSEGMENT,      /* maximum segment size */
    	CAMEL_SOCKOPT_BROADCAST,       /* enable broadcast */
    	CAMEL_SOCKOPT_LAST
    } CamelSockOpt;

### CamelLinger

    typedef struct linger CamelLinger;

### CamelSockOptData

    typedef struct {
    	CamelSockOpt option;
    	union {
    		guint       ip_ttl;              /* IP time to live */
    		guint       mcast_ttl;           /* IP multicast time to live */
    		guint       tos;                 /* IP type of service and precedence */
    		gboolean    non_blocking;        /* Non-blocking (network) I/O */
    		gboolean    reuse_addr;          /* Allow local address reuse */
    		gboolean    keep_alive;          /* Keep connections alive */
    		gboolean    mcast_loopback;      /* IP multicast loopback */
    		gboolean    no_delay;            /* Don't delay send to coalesce packets */
    		gboolean    broadcast;           /* Enable broadcast */
    		size_t      max_segment;         /* Maximum segment size */
    		size_t      recv_buffer_size;    /* Receive buffer size */
    		size_t      send_buffer_size;    /* Send buffer size */
    		CamelLinger linger;              /* Time to linger on close if data present */
    	} value;
    } CamelSockOptData;

### camel_tcp_stream_connect ()

    int                 camel_tcp_stream_connect            (CamelTcpStream *stream,
                                                             struct addrinfo *host);

Create a socket and connect based upon the data provided.

`stream` :

  a CamelTcpStream object

`host` :

  a linked list of addrinfo structures to try to connect, in the order of most likely to least likely to work.

Returns :

  `0` on success or `-1` on fail

### camel_tcp_stream_getsockopt ()

    int                 camel_tcp_stream_getsockopt         (CamelTcpStream *stream,
                                                             CamelSockOptData *data);

Get the socket options set on the stream and populate `data`.

`stream` :

  a CamelTcpStream object

`data` :

  socket option data

Returns :

  `0` on success or `-1` on fail

### camel_tcp_stream_setsockopt ()

    int                 camel_tcp_stream_setsockopt         (CamelTcpStream *stream,
                                                             const CamelSockOptData *data);

Set the socket options contained in `data` on the stream.

`stream` :

  a CamelTcpStream object

`data` :

  socket option data

Returns :

  `0` on success or `-1` on fail