Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

packetstream.h File Reference


Detailed Description

Needs short description here.

Author:
Jeroen Asselman
Date:
2004

#include <glib.h>
#include "packet.h"

Go to the source code of this file.

Typedefs

typedef g2packetstream_s g2packetstream_t

Functions

g2packetstream_tg2_packetstream_new (gpointer *connection)
 Allocate a new packet stream.

g2packetstream_tg2_packetstream_get (gpointer *connection)
 Get a packet stream for the given connection.

void g2_packetstream_free (gpointer *connection)
 Free a packet stream from memory.

int g2_packetstream_put_data (g2packetstream_t *stream, char *data, int length)
 Put data in a given packet stream.

g2packet_tg2_packetstream_get_packet (g2packetstream_t *stream)
 Get a packet from the packetstream.

int g2_packetstream_get_error (g2packetstream_t *stream, char **errormessage)
 Gets an error from the packetstream.


Typedef Documentation

typedef struct g2packetstream_s g2packetstream_t
 


Function Documentation

void g2_packetstream_free gpointer *  connection  ) 
 

Free a packet stream from memory.

g2packetstream_t* g2_packetstream_get gpointer *  connection  ) 
 

Get a packet stream for the given connection.

Returns the g2 packet stream associated with the given pointer. If no packetstream could be found, NULL is returned.

Parameters:
connection the connection to lookup.
Returns:
the packetstream associated with the given connection.

int g2_packetstream_get_error g2packetstream_t stream,
char **  errormessage
 

Gets an error from the packetstream.

Gets an error, if any, from the packetstream. Any error indication could indicate out of sync and as a result the connection should be dropped.

Parameters:
stream a pointer to the stream from which to retreive the error message.
errormessage a pointer where the errormessage string is written.
Returns:
0 on no error.

g2packet_t* g2_packetstream_get_packet g2packetstream_t stream  ) 
 

Get a packet from the packetstream.

Gets a packet from the packetstream, if there are no packets available, NULL is returned.

Parameters:
stream a pointer to the stream to retreive the packet from.
Returns:
a pointer to the packet, or NULL if no packets available.

g2packetstream_t* g2_packetstream_new gpointer *  connection  ) 
 

Allocate a new packet stream.

Allocates a new packet stream with the given connection as an identifier. Or if the connection allready exists, the existing connection is returned.

Parameters:
connection will be used as the identifier later for lookup (get)
Returns:
a new g2packetstream.

int g2_packetstream_put_data g2packetstream_t stream,
char *  data,
int  length
 

Put data in a given packet stream.

Puts received data in the given packet stream.

Parameters:
stream a pointer to the stream to which the data shall be written.
data a pointer to the data that shall be written.
length the amount of data that shall be written.
Returns:
the amount of bytes expected to be read additionally, never put more data than was requested or packets might get lost. 0 is returned if a full packet has been read and should be retreived first.


Generated on Sun Feb 12 10:50:05 2006 for Gtk-Gnutella by doxygen 1.3.6