netfunctions.c File Reference

This file implements the network functions for our application. More...

#include "netfunctions.h"
#include "logger.h"
#include <netdb.h>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>

Include dependency graph for netfunctions.c:

Go to the source code of this file.

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 makeSocket ()
 Internal function which will provide a socket to makeSimpleClientSock() and makeSimpleServerSock() with some basic values.
int hasData (int sock, struct timeval *timeout)

Variables

WINDOW * netLogWindow = NULL


Detailed Description

This file implements the network functions for our application.

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

Definition in file netfunctions.c.


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.

int makeSocket (  ) 

Internal function which will provide a socket to makeSimpleClientSock() and makeSimpleServerSock() with some basic values.

For internal use only.

Returns:
A new initialized socket or -1 if no socket could be obtained.

Definition at line 166 of file netfunctions.c.


Variable Documentation

WINDOW* netLogWindow = NULL

Definition at line 34 of file netfunctions.c.


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