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

nsnet.h File Reference

#include <nsutil.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>

Go to the source code of this file.

Data Structures

struct  InputBuffer
struct  OutputBuffer

Defines

#define CHUNKSIZE   256
#define DEFAULTPORT   8336
#define DEFAULTHOST   "localhost"
#define MAXCLIENTS   16
#define sock_t   int
#define rsockaddr_t   struct sockaddr_in

Typedefs

typedef hostent * hostent_t

Functions

sock_t rsocket (void)
int readline (sock_t fd, char *vptr, size_t maxlen, struct InputBuffer *ib)
const char * stringifyErrorCode (int code)
int rbindAll (sock_t sock_fd)
int writeBytes (sock_t con, const char *buf, int size, struct OutputBuffer *ob)
int writeString (sock_t con, const char *buf, struct OutputBuffer *ob)
int rconnectName (sock_t sock_fd, const char *hostname, unsigned short portno)
int rinitNetworking (void)
sock_t raccept (sock_t sock_fd)
void setblocking (sock_t sock_fd)
void setnonblocking (sock_t sock_fd)
void rshutdown (sock_t fd)
int getResponseCode (sock_t sock_fd, struct InputBuffer *)
 Returns 1 if EOF.

int getOK (sock_t sock_fd, struct InputBuffer *)
int rrecv (sock_t fd, char *read_buf, size_t count)
void initInputBuffer (struct InputBuffer *ib)
void initOutputBuffer (struct OutputBuffer *ob)
int isEOF (sock_t con, const struct InputBuffer *ib)
int inputBufferEmpty (const struct InputBuffer *ib)
int my_read (sock_t fd, char *ptr, size_t maxlen, struct InputBuffer *)
size_t readlinebuf (void **vptrptr, struct InputBuffer *)
size_t writen (sock_t fd, const void *vptr, size_t len, struct OutputBuffer *ob)
size_t readn (sock_t fd, void *vptr, size_t len, struct InputBuffer *ib)
int rselect (sock_t max_fd, fd_set *read, fd_set *write, fd_set *err)
int rselect_timed (sock_t max_fd, fd_set *toread, fd_set *towrite, fd_set *toerr, struct timeval *tv)
int findFdIndex (sock_t fd)
 Searches for a given socket fd in the handler table, fdTable, returning index or -1 if not found.


Define Documentation

#define CHUNKSIZE   256
 

Definition at line 30 of file nsnet.h.

#define DEFAULTHOST   "localhost"
 

Definition at line 33 of file nsnet.h.

Referenced by main(), and printHelp().

#define DEFAULTPORT   8336
 

Definition at line 32 of file nsnet.h.

Referenced by main(), printHelp(), and rbindAll().

#define MAXCLIENTS   16
 

Definition at line 34 of file nsnet.h.

Referenced by attemptBind(), and rbindAll().

#define rsockaddr_t   struct sockaddr_in
 

Definition at line 53 of file nsnet.h.

Referenced by attemptBind(), attemptConnect(), raccept(), rbindAll(), and rconnectName().

#define sock_t   int
 

Definition at line 52 of file nsnet.h.

Referenced by attemptBind(), attemptConnect(), main(), raccept(), rsocket(), and waitForNetEvent().


Typedef Documentation

typedef struct hostent* hostent_t
 

Definition at line 51 of file nsnet.h.

Referenced by rconnectName().


Function Documentation

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
 

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
 

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().

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 my_read sock_t  fd,
char *  ptr,
size_t  maxlen,
struct InputBuffer
 

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
 

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 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 *  read,
fd_set *  write,
fd_set *  err
 

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().

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().

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().


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