netfunctions.h File Reference

This file contains definitions needed to use the tine netfunctions library. More...

#include <sys/time.h>
#include <ncurses.h>

Include dependency graph for netfunctions.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ACCEPTSTAT_DELAYED   0
 Accepting a connection was delayed (no connection present).
#define ACCEPTSTAT_OK   1
 Connection has been successfully accepted.
#define ACCEPTSTAT_ERROR   -1
 There was an error accepting a connection.

Functions

int acceptConnection (int serverSock, int timeout, int *status)
 Internal function which implements non-blocking waiting for a connection.
int makeSimpleServSock (const unsigned short port)
 This function will initialize a simple TCP server listening on a port on all available interfaces.
int makeSimpleClientSock (const char *servName, const unsigned short port)
 This function will initialize a simple TCP socket which can be used to act as a TCP client.
int hasData (int sock, struct timeval *timeout)

Variables

WINDOW * netLogWindow


Detailed Description

This file contains definitions needed to use the tine netfunctions library.

Those network functions are intended to abstract some some processes in TCP/IP communication and by doing so save the other modules from beeing cluttered with net communications details.

Version:
Id
netfunctions.h,v 1.6 2008/09/18 12:59:02 prokop Exp

Definition in file netfunctions.h.


Define Documentation

#define ACCEPTSTAT_DELAYED   0

Accepting a connection was delayed (no connection present).

Definition at line 37 of file netfunctions.h.

#define ACCEPTSTAT_ERROR   -1

There was an error accepting a connection.

Definition at line 41 of file netfunctions.h.

#define ACCEPTSTAT_OK   1

Connection has been successfully accepted.

Definition at line 39 of file netfunctions.h.


Function Documentation

int acceptConnection ( int  serverSock,
int  timeout,
int *  status 
) [inline]

Internal function which implements non-blocking waiting for a connection.

We cannot afford a blocking accept(), because we would miss a quit request.

Parameters:
serverSock A listening server socket from which we get the connection.
timeout Timeout (in seconds) which to wait for a connection
status Status of the new connection. Can be one of # ACCEPTSTAT_DELAYED - so far no connection has been made # ACCEPTSTAT_OK - new connection has been successfully established # ACCEPTSTAT_ERROR - there was an error
Returns:
new connection socket or -1 on error.

Definition at line 36 of file netfunctions.c.

int hasData ( int  sock,
struct timeval *  timeout 
) [inline]

Definition at line 178 of file netfunctions.c.

int makeSimpleClientSock ( const char *  servName,
const unsigned short  port 
)

This function will initialize a simple TCP socket which can be used to act as a TCP client.

No binding will be done. In case of error use perror() to get a message.

Parameters:
servName Name of the server we want to connect to, not it's address (in particular: anything what gethostbyname() will accept.
port port address to connect to
Returns:
An initialized TCP socket suitable for client applications or -1 on any error.

Definition at line 121 of file netfunctions.c.

int makeSimpleServSock ( const unsigned short  port  ) 

This function will initialize a simple TCP server listening on a port on all available interfaces.

In case of error use perror() to get a message.

Parameters:
port The TCP port to listen on
Returns:
An initialized TCP socket which has been bound to the given port or -1 on any error (socket error, binding error, port in use, etc.)

Definition at line 70 of file netfunctions.c.


Variable Documentation

WINDOW* netLogWindow

Definition at line 34 of file netfunctions.c.


Generated on Sun Sep 28 21:20:01 2008 for Guard by  doxygen 1.5.6