Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

socketcommon.h File Reference

Wrap functions for altsocklib. More...

Go to the source code of this file.

Data Structures

struct  sock_state_t
 A generic server state. More...


strings prepended to log lines

#define SOCK_ERROR   "!! "
#define SOCK_INFO   "?? "
#define SOCK_SENT   "-> "
#define SOCK_RECEIVED   "<- "

Function for logging

All these functions are used internally by socketcommon, but can be used to make erta loggin outside this module.

void sock_print (char *prebuffer, char *buffer, struct sock_state_t *s)
 generic print on log file

void sock_error (char *type, int ernum, struct sock_state_t *s)
 error print on log file

void sock_received (char *buffer, struct sock_state_t *s)
 received print on log file

void sock_sent (char *buffer, struct sock_state_t *s)
 sent print on log file

void sock_info (char *buffer, struct sock_state_t *s)
 info print on log file


Communication functions

These are for sending and receiveing.

void sock_send (struct sock_state_t *s, char *buffer)
 send buffer on s, remember that "\r\n" will be appended to buffer

void sock_sendraw (struct sock_state_t *s, char *buffer)
 send buffer on s, with no "\r\n" at the end

int sock_receive (struct sock_state_t *s, char *buffer, int maxlen)
 receive maxlen into buffer with "\r\n" stripped

int sock_receive_with_timeout (struct sock_state_t *s, char *buffer, int maxlen, int timeout)
 receive with timeout in seconds


Client/Server functions

These are for starting a client or a server.

sock_state_tsock_connect (char *hostname, unsigned long port, int maxlinelen, void(*print)(char *))
 connect to a server

void sock_disconnect (struct sock_state_t *s)
 close the socket and free the structure s

sock_state_tsock_bind (struct in_addr bind_add, unsigned short port, int maxlinelen, void(*print)(char *))
 bind a socket and listen on it

sock_state_tsock_listen (struct sock_state_t *s)
 this is the accept, returns the new socket that must be freed by the caller


Detailed Description

Wrap functions for altsocklib.

Author:
Enrico Tassi   <sorry guy>

Definition in file socketcommon.h.


Define Documentation

#define SOCK_ERROR   "!! "
 

Definition at line 34 of file socketcommon.h.

#define SOCK_INFO   "?? "
 

Definition at line 35 of file socketcommon.h.

#define SOCK_RECEIVED   "<- "
 

Definition at line 37 of file socketcommon.h.

#define SOCK_SENT   "-> "
 

Definition at line 36 of file socketcommon.h.


Function Documentation

struct sock_state_t* sock_bind struct in_addr  bind_add,
unsigned short  port,
int  maxlinelen,
void(*  print)(char *)
 

bind a socket and listen on it

struct sock_state_t* sock_connect char *  hostname,
unsigned long  port,
int  maxlinelen,
void(*  print)(char *)
 

connect to a server

void sock_disconnect struct sock_state_t s  ) 
 

close the socket and free the structure s

void sock_error char *  type,
int  ernum,
struct sock_state_t s
 

error print on log file

void sock_info char *  buffer,
struct sock_state_t s
 

info print on log file

struct sock_state_t* sock_listen struct sock_state_t s  ) 
 

this is the accept, returns the new socket that must be freed by the caller

void sock_print char *  prebuffer,
char *  buffer,
struct sock_state_t s
 

generic print on log file

int sock_receive struct sock_state_t s,
char *  buffer,
int  maxlen
 

receive maxlen into buffer with "\r\n" stripped

int sock_receive_with_timeout struct sock_state_t s,
char *  buffer,
int  maxlen,
int  timeout
 

receive with timeout in seconds

void sock_received char *  buffer,
struct sock_state_t s
 

received print on log file

void sock_send struct sock_state_t s,
char *  buffer
 

send buffer on s, remember that "\r\n" will be appended to buffer

void sock_sendraw struct sock_state_t s,
char *  buffer
 

send buffer on s, with no "\r\n" at the end

void sock_sent char *  buffer,
struct sock_state_t s
 

sent print on log file


Generated on Wed May 5 15:48:04 2004 for LiberoPOPs by doxygen 1.3.6-20040222