Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

jbsockets.h File Reference

Contains wrappers for system-specific sockets code, so that the rest of Junkbuster can be more OS-independent. More...

Go to the source code of this file.

Defines

#define JBSOCKETS_H_VERSION   "$Id: jbsockets.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"

Functions

jb_socket connect_to (const char *host, int portnum, struct client_state *csp)
int write_socket (jb_socket fd, const char *buf, size_t n)
int read_socket (jb_socket fd, char *buf, int n)
void close_socket (jb_socket fd)
int bind_port (const char *hostnam, int portnum, jb_socket *pfd)
int accept_connection (struct client_state *csp, jb_socket fd)
unsigned long resolve_hostname_to_ip (const char *host)

Variables

const char jbsockets_rcs []
const char jbsockets_h_rcs []


Detailed Description

Contains wrappers for system-specific sockets code, so that the rest of Junkbuster can be more OS-independent.

Contains ifdefs to make this work on many platforms.

Log:
jbsockets.h,v
Revision 2.0 2002/06/04 14:34:21 jongfoster Moving source files to src/

Revision 1.10 2002/05/26 23:23:10 joergs AmigaOS: Fixed wrong type for len in write_socket()

Revision 1.9 2002/04/08 20:31:41 swa fixed JB spelling

Revision 1.8 2002/03/26 22:29:54 swa we have a new homepage!

Revision 1.7 2002/03/24 13:25:43 swa name change related issues

Revision 1.6 2002/03/13 00:27:05 jongfoster Killing warnings

Revision 1.5 2002/03/09 20:03:52 jongfoster

THIS WAS A MAJOR BUG - it caused frequent, unpredictable crashes, and also frequently caused JB to jump to 100% CPU and stay there. (Because it thought it had just read ((unsigned)-1) == 4Gb of data...)

Revision 1.4 2002/03/07 03:51:36 oes Revision 1.3 2001/07/29 19:01:11 jongfoster Changed _FILENAME_H to FILENAME_H_INCLUDED. Added forward declarations for needed structures.

Revision 1.2 2001/06/07 23:06:09 jongfoster The host parameter to connect_to() is now const.

Revision 1.1.1.1 2001/05/15 13:58:54 oes Initial import of version 2.9.3 source tree


Function Documentation

int accept_connection struct client_state   csp,
jb_socket    fd
 

Accepts a connection on a socket.

Socket must have been created using bind_port().

Parameters:
csp  Client state, cfd, ip_addr_str, and ip_addr_long will be set by this routine.
fd  file descriptor returned from bind_port
Returns:
when a connection is accepted, it returns 1 (TRUE). On an error it returns 0 (FALSE).

int bind_port const char *    hostnam,
int    portnum,
jb_socket   pfd
 

Call socket, set socket options, and listen.

Called by listen_loop to "boot up" our proxy address.

Parameters:
hostnam  TCP/IP address to bind/listen to
portnum  port to listen on
pfd  pointer used to return file descriptor.
Returns:
if success, returns 0 and sets *pfd. if failure, returns -3 if address is in use, -2 if address unresolvable, -1 otherwise

void close_socket jb_socket    fd
 

Closes a TCP/IP socket.

Parameters:
fd  file descriptor of socket to be closed
Returns:
void

jb_socket connect_to const char *    host,
int    portnum,
struct client_state   csp
 

Open a socket and connect to it.

Will check that this is allowed according to ACL.

Parameters:
host  hostname to connect to
portnum  port to connent on
csp  Current client state (buffers, headers, etc...) Not modified, only used for source IP and ACL.
Returns:
JB_INVALID_SOCKET => failure, else it is the socket file descriptor.

int read_socket jb_socket    fd,
char *    buf,
int    len
 

Read from a TCP/IP socket in a platform independent way.

Parameters:
fd  file descriptor of the socket to read
buf  pointer to buffer where data will be written Must be >= len bytes long.
len  maximum number of bytes to read
Returns:
On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number. It is not an error if this number is smaller than the number of bytes requested; this may hap- pen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal, or because read() was interrupted by a signal). On error, -1 is returned, and errno is set appropriately. In this case it is left unspecified whether the file position (if any) changes.

unsigned long resolve_hostname_to_ip const char *    host
 

Resolve a hostname to an internet tcp/ip address.

NULL or an empty string resolve to INADDR_ANY.

Parameters:
host  hostname to resolve
Returns:
INADDR_NONE => failure, INADDR_ANY or tcp/ip address if succesful.

int write_socket jb_socket    fd,
const char *    buf,
size_t    len
 

Write the contents of buf (for n bytes) to socket fd.

Parameters:
fd  file descriptor (aka. handle) of socket to write to.
buf  pointer to data to be written.
len  length of data to be written to the socket "fd".
Returns:
0 on success (entire buffer sent). nonzero on error.


Variable Documentation

const char jbsockets_h_rcs[]
 

Version information about jbsockets.h.

const char jbsockets_rcs[]
 

Version information about jbsockets.c.


Generated on Tue Jun 4 18:54:49 2002 for Privoxy 3.1.1 by doxygen1.2.15