Distributed Hash Table File System for Linux








net_layer.c File Reference

#include "magma.h"

Defines

#define REUSE_SOCKETS   1

Functions

int get_client_socket (char *ipaddr, int port)
int xsend (int s, const void *buf, size_t size)
int xread (int s, void *buf, size_t size)
int netstrcpy_single_char (int s, char *string, int max)
int netstrcpy_peek (int s, char *string, int max)
int xnetstrcpy (int s, char **string, int max)
int cnetstrsend (int s, const char *string)
int cnetstrcpy (int s, char **string)
void transmit_heartbeat (int s, struct sockaddr_in *peer, socklen_t *peer_len)

Variables

uint16_t heartbeat = 1

Define Documentation

#define REUSE_SOCKETS   1


Function Documentation

int cnetstrcpy ( int  s,
char **  string 
)

Counterpart of cnetstrsend. *string is dynamically allocated and should be freed by outside code.

Parameters:
s network socket
string memory buffer which contains the string to be sent
Returns:
read bytes

int cnetstrsend ( int  s,
const char *  string 
)

Send a string over the wire using a counter on top of it to transmit string length

Parameters:
s network socket
string memory buffer which contains the string to be sent
Returns:
sent bytes

int get_client_socket ( char *  ipaddr,
int  port 
)

provides a network socket initialized for flare protocol

Parameters:
ipaddr string rappresenting remote IP address
port remote port
Returns:
new socket, 0 on failure

int netstrcpy_peek ( int  s,
char *  string,
int  max 
)

copy a string of max chars directly from the network socket s. this variant uses TCP peek option to inspect available data without removing it from the buffer

Parameters:
s network socket
string memory buffer to save the string to be received
max dimension of memory buffer string
Returns:
read bytes

int netstrcpy_single_char ( int  s,
char *  string,
int  max 
)

copy a string of max chars directly from the network socket s. this variant read 1 char at time until \0 is reached

Parameters:
s network socket
string memory buffer to save the string to be received
max dimension of memory buffer string
Returns:
read bytes

void transmit_heartbeat ( int  s,
struct sockaddr_in *  peer,
socklen_t *  peer_len 
)

transmit 1 if server is still alive.

Parameters:
s network socket
peer remote address
peer_len size of peer structure

int xnetstrcpy ( int  s,
char **  string,
int  max 
)

copy a string of max chars directly from the network socket s. *string buffer is dynamically allocated and should be freed by outside code.

Parameters:
s network socket
string memory buffer to save the string to be received
max dimension of memory buffer string
Returns:
read bytes

int xread ( int  s,
void *  buf,
size_t  size 
)

try to read as many bytes as needed

Parameters:
s network socket
buf memory area to save incoming data
size dimension of memory area pointed by buf
Returns:
read bytes

int xsend ( int  s,
const void *  buf,
size_t  size 
)

Guarantee that all provided buffer will be delivered over the wire

Parameters:
s network socket
buf the buffer to be written
size buffer size to be written
Returns:
sent bytes


Variable Documentation

uint16_t heartbeat = 1

integer used to transmit 1 to answer to heartbeat operation

This file last modified Wednesday, 09-Jan-2008 20:02:34 CET