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

nsnet.c File Reference

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <nsnet.h>
#include <nsutil.h>
#include <monitor.h>
#include <signal.h>

Go to the source code of this file.

Data Structures

struct  FDHandlerEntry

Defines

#define NUM_WRITEN   1
#define NUM_READN   2
#define NUM_MYREAD   3
#define NUM_READLINE   4
#define NUM_WRITEN2   5
#define NUM_MAX   6
#define NUM_QUIET
#define MAXHANDLER   1024
#define MAXREAD   16384

Functions

void addCount (int where)
void showCounts ()
int isEOF (sock_t con, const struct InputBuffer *ib)
const char * stringifyErrorCode (int code)
void rshutdown (sock_t fd)
void setblocking (sock_t sock_fd)
void setnonblocking (sock_t sock_fd)
sock_t rsocket (void)
void sigPIPEHandler (int i)
int rinitNetworking (void)
int rbindAll (sock_t sock_fd)
int rconnectName (sock_t sock_fd, const char *hostname, unsigned short portno)
sock_t raccept (sock_t sock_fd)
int writeString (sock_t con, const char *buf, struct OutputBuffer *ob)
int rrecv (sock_t fd, char *read_buf, size_t count)
int writeBytes (sock_t con, const char *buf, int size, struct OutputBuffer *ob)
void initOutputBuffer (struct OutputBuffer *ob)
void initInputBuffer (struct InputBuffer *ib)
int my_read (sock_t fd, char *ptr, size_t maxlen, struct InputBuffer *ib)
size_t readn (sock_t fd, void *vptr, size_t len, struct InputBuffer *ib)
size_t writen (sock_t fd, const void *vptr, size_t len, struct OutputBuffer *ob)
size_t readlinebuf (void **vptrptr, struct InputBuffer *ib)
int inputBufferEmpty (const struct InputBuffer *ib)
int getOK (sock_t sock_fd, struct InputBuffer *ib)
int getResponseCode (sock_t sock_fd, struct InputBuffer *ib)
 Returns 1 if EOF.

int rselect_timed (sock_t max_fd, fd_set *toread, fd_set *towrite, fd_set *toerr, struct timeval *tv)
int rselect (sock_t max_fd, fd_set *toread, fd_set *towrite, fd_set *toerr)
int readline (sock_t fd, char *vptr, size_t maxlen, struct InputBuffer *ib)
int findFdIndex (sock_t fd)
 Searches for a given socket fd in the handler table, fdTable, returning index or -1 if not found.

int makeNewEntryForFD (sock_t fd, void(*handler)(void *uobj, const char *data, size_t len), void *uobj)
int setFdHandler (sock_t fd, void(*handler)(void *uobj, const char *data, size_t len), void *uobj)
int removeFdHandler (sock_t fd)
int handleReads (sock_t fd)

Variables

unsigned int cur [NUM_MAX]
unsigned int last [NUM_MAX]
FDHandlerEntry fdTable [MAXHANDLER]
int handlerCount


Define Documentation

#define MAXHANDLER   1024
 

Definition at line 560 of file nsnet.c.

Referenced by makeNewEntryForFD().

#define MAXREAD   16384
 

Definition at line 623 of file nsnet.c.

Referenced by handleReads().

#define NUM_MAX   6
 

Definition at line 49 of file nsnet.c.

Referenced by addCount(), and showCounts().

#define NUM_MYREAD   3
 

Definition at line 45 of file nsnet.c.

Referenced by my_read().

#define NUM_QUIET
 

Definition at line 52 of file nsnet.c.

#define NUM_READLINE   4
 

Definition at line 46 of file nsnet.c.

Referenced by readline().

#define NUM_READN   2
 

Definition at line 44 of file nsnet.c.

Referenced by readn().

#define NUM_WRITEN   1
 

Definition at line 43 of file nsnet.c.

Referenced by writen().

#define NUM_WRITEN2   5
 

Definition at line 47 of file nsnet.c.

Referenced by writen().


Function Documentation

void addCount int  where  ) 
 

Definition at line 56 of file nsnet.c.

References cur, and NUM_MAX.

Referenced by my_read(), readline(), readn(), and writen().

int findFdIndex sock_t  fd  ) 
 

Searches for a given socket fd in the handler table, fdTable, returning index or -1 if not found.

Searches fdTable for the given fd in the array. Returns index if found.

Parameters:
fd the fd to search for
Returns:
The index where fd is found, or -1 if not found

Definition at line 575 of file nsnet.c.

References FDHandlerEntry::fd, fdTable, and handlerCount.

Referenced by handleReads(), removeFdHandler(), and setFdHandler().

int getOK sock_t  sock_fd,
struct InputBuffer ib
 

Definition at line 464 of file nsnet.c.

References getResponseCode(), ib, rprintf(), and sock_fd.

Referenced by main().

int getResponseCode sock_t  sock_fd,
struct InputBuffer ib
 

Returns 1 if EOF.

Definition at line 482 of file nsnet.c.

References ib, isEOF(), MAXLEN, readline(), and sock_fd.

Referenced by getOK(), and main().

int handleReads sock_t  fd  ) 
 

Definition at line 624 of file nsnet.c.

References fdTable, findFdIndex(), FDHandlerEntry::handler, MAXREAD, and rrecv().

void initInputBuffer struct InputBuffer ib  ) 
 

Definition at line 362 of file nsnet.c.

References ib.

Referenced by makeNewClient().

void initOutputBuffer struct OutputBuffer ob  ) 
 

Definition at line 357 of file nsnet.c.

References ob.

Referenced by makeNewClient().

int inputBufferEmpty const struct InputBuffer ib  ) 
 

Definition at line 459 of file nsnet.c.

References ib, and InputBuffer::read_cnt.

Referenced by main().

int isEOF sock_t  con,
const struct InputBuffer ib
 

Definition at line 76 of file nsnet.c.

References ib, and InputBuffer::isEOF.

Referenced by getResponseCode(), idleHandler(), and main().

int makeNewEntryForFD sock_t  fd,
void(*  handler)(void *uobj, const char *data, size_t len),
void *  uobj
 

Definition at line 584 of file nsnet.c.

References FDHandlerEntry::fd, fdTable, FDHandlerEntry::handler, handlerCount, MAXHANDLER, rprintf(), and FDHandlerEntry::uobj.

Referenced by setFdHandler().

int my_read sock_t  fd,
char *  ptr,
size_t  maxlen,
struct InputBuffer ib
 

Definition at line 367 of file nsnet.c.

References addCount(), ib, InputBuffer::isEOF, monitorLog(), NUM_MYREAD, PLACE_MYREAD, InputBuffer::read_buf, InputBuffer::read_cnt, InputBuffer::read_ptr, rprintf(), rrecv(), and showCounts().

Referenced by main(), and readline().

sock_t raccept sock_t  sock_fd  ) 
 

Definition at line 285 of file nsnet.c.

References rprintf(), rsockaddr_t, sock_fd, sock_t, and stringifyErrorCode().

Referenced by main().

int rbindAll sock_t  sock_fd  ) 
 

Definition at line 213 of file nsnet.c.

References DEFAULTPORT, MAXCLIENTS, rexit(), rprintf(), rsockaddr_t, and sock_fd.

Referenced by main().

int rconnectName sock_t  sock_fd,
const char *  hostname,
unsigned short  portno
 

Definition at line 244 of file nsnet.c.

References hostent_t, monitorLog(), PLACE_CONNECT, rexit(), rprintf(), rsleep(), rsockaddr_t, and sock_fd.

Referenced by main().

int readline sock_t  fd,
char *  vptr,
size_t  maxlen,
struct InputBuffer ib
 

Definition at line 529 of file nsnet.c.

References addCount(), ib, my_read(), NUM_READLINE, setblocking(), and showCounts().

Referenced by getResponseCode(), idleHandler(), and main().

size_t readlinebuf void **  vptrptr,
struct InputBuffer ib
 

Definition at line 452 of file nsnet.c.

References ib, InputBuffer::read_cnt, and InputBuffer::read_ptr.

size_t readn sock_t  fd,
void *  vptr,
size_t  len,
struct InputBuffer ib
 

Definition at line 409 of file nsnet.c.

References addCount(), NUM_READN, and showCounts().

int removeFdHandler sock_t  fd  ) 
 

Definition at line 611 of file nsnet.c.

References fdTable, findFdIndex(), and handlerCount.

int rinitNetworking void   ) 
 

Definition at line 198 of file nsnet.c.

References sigPIPEHandler().

Referenced by main().

int rrecv sock_t  fd,
char *  read_buf,
size_t  count
 

Definition at line 315 of file nsnet.c.

References monitorLog(), and PLACE_RRECV.

Referenced by handleReads(), and my_read().

int rselect sock_t  max_fd,
fd_set *  toread,
fd_set *  towrite,
fd_set *  toerr
 

Definition at line 512 of file nsnet.c.

References max_fd, monitorLog(), and PLACE_RSELECT.

Referenced by idleHandler(), and main().

int rselect_timed sock_t  max_fd,
fd_set *  toread,
fd_set *  towrite,
fd_set *  toerr,
struct timeval *  tv
 

Definition at line 504 of file nsnet.c.

References max_fd.

Referenced by main().

void rshutdown sock_t  fd  ) 
 

Definition at line 124 of file nsnet.c.

Referenced by main().

sock_t rsocket void   ) 
 

Definition at line 186 of file nsnet.c.

References setnonblocking(), sock_fd, and sock_t.

Referenced by main().

void setblocking sock_t  sock_fd  ) 
 

Definition at line 133 of file nsnet.c.

References monitorLog(), PLACE_SETBLOCKING, rexit(), and sock_fd.

Referenced by main(), readline(), and writeBytes().

int setFdHandler sock_t  fd,
void(*  handler)(void *uobj, const char *data, size_t len),
void *  uobj
 

Definition at line 598 of file nsnet.c.

References fdTable, findFdIndex(), FDHandlerEntry::handler, makeNewEntryForFD(), and FDHandlerEntry::uobj.

void setnonblocking sock_t  sock_fd  ) 
 

Definition at line 160 of file nsnet.c.

References rexit(), rprintf(), and sock_fd.

Referenced by rsocket(), and writeBytes().

void showCounts  ) 
 

Definition at line 62 of file nsnet.c.

References cur, NUM_MAX, and rprintf().

Referenced by my_read(), readline(), readn(), and writen().

void sigPIPEHandler int  i  ) 
 

Definition at line 194 of file nsnet.c.

Referenced by rinitNetworking().

const char* stringifyErrorCode int  code  ) 
 

Definition at line 81 of file nsnet.c.

References buf, and OSTYPESTR.

Referenced by monitorLog(), and raccept().

int writeBytes sock_t  con,
const char *  buf,
int  size,
struct OutputBuffer ob
 

Definition at line 334 of file nsnet.c.

References buf, MAXLEN, monitorLog(), PLACE_WRITEBYTES, rprintf(), setblocking(), and setnonblocking().

Referenced by main(), and writeString().

size_t writen sock_t  fd,
const void *  vptr,
size_t  len,
struct OutputBuffer ob
 

Definition at line 430 of file nsnet.c.

References addCount(), NUM_WRITEN, NUM_WRITEN2, and showCounts().

Referenced by handleSamples(), and sendClientMsg().

int writeString sock_t  con,
const char *  buf,
struct OutputBuffer ob
 

Definition at line 310 of file nsnet.c.

References buf, ob, and writeBytes().

Referenced by handleSamples(), and main().


Variable Documentation

unsigned int cur[NUM_MAX]
 

Definition at line 54 of file nsnet.c.

Referenced by addCount(), idleHandler(), main(), and showCounts().

struct FDHandlerEntry fdTable[MAXHANDLER]
 

Definition at line 567 of file nsnet.c.

Referenced by findFdIndex(), handleReads(), makeNewEntryForFD(), removeFdHandler(), and setFdHandler().

int handlerCount
 

Table of stream handlers *

Definition at line 568 of file nsnet.c.

Referenced by findFdIndex(), makeNewEntryForFD(), and removeFdHandler().

unsigned int last[NUM_MAX]
 

Definition at line 54 of file nsnet.c.


Generated on Tue Feb 8 00:05:18 2005 for Neuroserver by doxygen 1.3.3