Main Page | Class List | File List | Class Members | File Members | Related Pages

tcpc.h File Reference

High-level TCP connection abstraction. More...

#include "fdbuf.h"

Go to the source code of this file.

Classes

struct  tcp_conn

Typedefs

typedef tcp_conn TCPC
typedef TCPC Connection

Functions

EXTERN_C_BEGIN LIBGIFT_EXPORT
TCPC
tcp_open (in_addr_t host, in_port_t port, int block)
LIBGIFT_EXPORT TCPCtcp_accept (TCPC *listening, int block)
LIBGIFT_EXPORT TCPCtcp_bind (in_port_t port, int block)
LIBGIFT_EXPORT void tcp_close (TCPC *c)
LIBGIFT_EXPORT void tcp_close_null (TCPC **c)
LIBGIFT_EXPORT int tcp_flush (TCPC *c, int write)
LIBGIFT_EXPORT int tcp_write (TCPC *c, unsigned char *data, size_t len)
LIBGIFT_EXPORT int tcp_writestr (TCPC *c, char *data)
LIBGIFT_EXPORT int tcp_send (TCPC *c, unsigned char *data, size_t len)
LIBGIFT_EXPORT FDBuftcp_readbuf (TCPC *c)
LIBGIFT_EXPORT int tcp_recv (TCPC *c, unsigned char *buf, size_t len)
LIBGIFT_EXPORT int tcp_peek (TCPC *c, unsigned char *buf, size_t len)


Detailed Description

High-level TCP connection abstraction.

This structure is passed along to pretty much every internal giFT function to encompass all the network functionality that will be required. Also the recommended method of interfacing with the event loop.


Typedef Documentation

typedef TCPC Connection
 

Backwards compatibility

typedef struct tcp_conn TCPC
 

Basic building block for all connections spawned using libgiFT. If you wish to use libgiFT at all, use these.


Function Documentation

LIBGIFT_EXPORT TCPC* tcp_accept TCPC listening,
int  block
 

Accepts an incoming socket connection.

See also:
tcp_open

net_accept

LIBGIFT_EXPORT TCPC* tcp_bind in_port_t  port,
int  block
 

Binds to the supplied port.

See also:
tcp_open

net_accept

net_bind

LIBGIFT_EXPORT void tcp_close TCPC c  ) 
 

Close (and free) a connection pointer.

Parameters:
c Location of the Connection structure.

LIBGIFT_EXPORT void tcp_close_null TCPC **  c  ) 
 

Wrapper for tcp_close that sets the calling argument to NULL afterwards.

Parameters:
c Address of a Connection pointer.

LIBGIFT_EXPORT int tcp_flush TCPC c,
int  write
 

Flush and destroy the pending write queue.

Parameters:
c 
write If TRUE, appropriate send calls will be performed. Otherwise, the data will simply be destroyed.
Returns:
Number of elements removed.

EXTERN_C_BEGIN LIBGIFT_EXPORT TCPC* tcp_open in_addr_t  host,
in_port_t  port,
int  block
 

Creates a new connection structure and attempts an outgoing TCP connection using net_connect.

See also:
net_connect
Returns:
Pointer to a dynamically allocated Connection structure.

LIBGIFT_EXPORT int tcp_peek TCPC c,
unsigned char *  buf,
size_t  len
 

Identical to tcp_recv, except that recv is given the MSG_PEEK option.

LIBGIFT_EXPORT FDBuf* tcp_readbuf TCPC c  ) 
 

Accessor for the buffer object.

LIBGIFT_EXPORT int tcp_recv TCPC c,
unsigned char *  buf,
size_t  len
 

Direct recv wrapper to maintain a consistent interface.

LIBGIFT_EXPORT int tcp_send TCPC c,
unsigned char *  data,
size_t  len
 

Direct send wrapper to maintain a consistent interface.

LIBGIFT_EXPORT int tcp_write TCPC c,
unsigned char *  data,
size_t  len
 

Abstracted send call implemented with a user-space socket write queue to avoid flooding the kernel.

LIBGIFT_EXPORT int tcp_writestr TCPC c,
char *  data
 

Simple wrapper for tcp_write for NUL-terminated strings.


Generated on Sun Aug 22 08:07:11 2004 by doxygen 1.3.7