Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

vrpn_Connection.C File Reference


Compounds

class  vrpn_TranslationTable
struct  cRemoteMapping
class  vrpn_TypeDispatcher
struct  vrpn_TypeDispatcher::vrpnLocalMapping
class  vrpn_ConnectionManager
struct  vrpn_ConnectionManager::knownConnection
struct  vrpn_Synchronized_Connection

Defines

#define vrpn_closeSocket
#define SOCK_CAST
#define GSN_CAST
#define INVALID_SOCKET
#define RSH
#define UDP_CALL_TIMEOUT
#define UDP_CALL_RETRIES
#define SERVCOUNT
#define SERVWAIT
#define vrpn_CONNECTION_MAX_XLATION_TABLE_SIZE

Enumerations

enum  ConnectionStatus { LISTEN, CONNECTED, COOKIE_PENDING, TRYING_TO_CONNECT, BROKEN, LOGGING }

Functions

int vrpn_getmyIP (char * myIPchar, unsigned maxlen, const char * NIC_IP = NULL)
This function returns the host IP address in string form. More...

int vrpn_noint_select (int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval * timeout)
This routine will perform like a normal select() call, but it will restart if it quit because of an interrupt. More...

int vrpn_noint_block_write (int outfile, const char buffer[], int length)
This routine will write a block to a file descriptor. More...

int vrpn_noint_block_read (int infile, char buffer[], int length)
This routine will read in a block from the file descriptor. More...

int vrpn_noint_block_read_timeout (int infile, char buffer[], int length, struct timeval *timeout)
This routine will read in a block from the file descriptor. More...

SOCKET open_socket (int type, unsigned short * portno, const char * IPaddress)
This routine opens a socket with the requested port number. More...

SOCKET open_udp_socket (unsigned short * portno, const char * IPaddress)
Create a UDP socket and bind it to its local address.

SOCKET open_tcp_socket (unsigned short * portno = NULL, const char * NIC_IP = NULL)
Create a TCP socket and bind it to its local address.

SOCKET vrpn_connect_udp_port (const char * machineName, int remotePort, const char * NIC_IP = NULL)
Create a UDP socket and connect it to a specified port.

int vrpn_udp_request_lob_packet ( const char * machine, const int remote_port, const int local_port, const char * NIC_IP = NULL)
This section deals with implementing a method of connection termed a UDP request. More...

int vrpn_get_a_TCP_socket (SOCKET * listen_sock, int * listen_portnum, const char * NIC_IP = NULL)
This routine will get a TCP socket that is ready to accept connections. More...

int vrpn_poll_for_accept (SOCKET listen_sock, SOCKET *accept_sock, double timeout = 0.0)
This routine will check the listen socket to see if there has been a connection request. More...

int vrpn_start_server (const char * machine, char * server_name, char * args, const char * IPaddress = NULL)
This routine will start up a given server on a given machine. More...

int write_vrpn_cookie (char * buffer, int length, long remote_log_mode)
Writes the magic cookie into buffer with given length. More...

int check_vrpn_cookie (const char * buffer)
Checks to see if the given buffer has the magic cookie. More...

int check_vrpn_file_cookie (const char * buffer)
int vrpn_cookie_size (void)
void setClockOffset ( void *userdata, const vrpn_CLOCKCB& info )
int flush_udp_socket (int fd)
vrpn_Connectionvrpn_get_connection_by_name ( const char * cname, const char * local_in_logfile_name, const char * local_out_logfile_name, const char * remote_in_logfile_name, const char * remote_out_logfile_name, double dFreq, int cSyncWindow, const char * NIC_IPaddress)
char* vrpn_copy_service_name (const char * fullname)
char* vrpn_copy_service_location (const char * fullname)
char* vrpn_copy_file_name (const char * filespecifier)
int header_len (const char *hostspecifier)
char* vrpn_copy_machine_name (const char * hostspecifier)
int vrpn_get_port_number (const char * hostspecifier)
char* vrpn_copy_rsh_program (const char * hostspecifier)
char* vrpn_copy_rsh_arguments (const char * hostspecifier)

Variables

const char* vrpn_MAGIC
const char* vrpn_FILE_MAGIC
const int vrpn_MAGICLEN
const char* vrpn_got_first_connection
const char* vrpn_got_connection
const char* vrpn_dropped_connection
const char* vrpn_dropped_last_connection
const char* vrpn_CONTROL
vrpn_Synchronized_Connection connectionStatus


Define Documentation

#define vrpn_closeSocket ()

#define SOCK_CAST ()

#define GSN_CAST ()

#define INVALID_SOCKET ()

#define RSH ()

#define UDP_CALL_TIMEOUT ()

#define UDP_CALL_RETRIES ()

#define SERVCOUNT ()

#define SERVWAIT ()

#define vrpn_CONNECTION_MAX_XLATION_TABLE_SIZE ()


Enumeration Type Documentation

enum ConnectionStatus

Enumeration values:
LISTEN  
CONNECTED  
COOKIE_PENDING  
TRYING_TO_CONNECT  
BROKEN  
LOGGING  

Function Documentation

int vrpn_getmyIP (char * myIPchar, unsigned maxlen, const char * NIC_IP = NULL) [static]

This function returns the host IP address in string form.

For example, the machine "ioglab.cs.unc.edu" becomes "152.2.130.90." This is done so that the remote host can connect back even if it can't resolve the DNS name of this host. This is especially useful at conferences, where DNS may not even be running.

int vrpn_noint_select (int width, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval * timeout)

This routine will perform like a normal select() call, but it will restart if it quit because of an interrupt.

This makes it more robust in its function, and allows this code to perform properly on pxpl5, which sends USER1 interrupts while rendering an image.

int vrpn_noint_block_write (int outfile, const char buffer[], int length)

This routine will write a block to a file descriptor.

It acts just like the write() system call does on files, but it will keep sending to a socket until an error or all of the data has gone. This will also take care of problems caused by interrupted system calls, retrying the write when they occur. It will also work when sending large blocks of data through socket connections, since it will send all of the data before returning. This routine will either write the requested number of bytes and return that or return -1 (in the case of an error) or 0 (in the case of EOF being reached before all the data is sent).

int vrpn_noint_block_read (int infile, char buffer[], int length)

This routine will read in a block from the file descriptor.

It acts just like the read() routine does on normal files, so that it hides the fact that the descriptor may point to a socket. This will also take care of problems caused by interrupted system calls, retrying the read when they occur. This routine will either read the requested number of bytes and return that or return -1 (in the case of an error) or 0 (in the case of EOF being reached before all the data arrives).

int vrpn_noint_block_read_timeout (int infile, char buffer[], int length, struct timeval * timeout)

This routine will read in a block from the file descriptor.

It acts just like the read() routine on normal files, except that it will time out if the read takes too long. This will also take care of problems caused by interrupted system calls, retrying the read when they occur. This routine will either read the requested number of bytes and return that or return -1 (in the case of an error) or 0 (in the case of EOF being reached before all the data arrives), or return the number of characters read before timeout (in the case of a timeout).

SOCKET open_socket (int type, unsigned short * portno, const char * IPaddress) [static]

This routine opens a socket with the requested port number.

The routine returns -1 on failure and the file descriptor on success. The portno parameter is filled in with the actual port that is opened (this is useful when the address INADDR_ANY is used, since it tells what port was opened). To select between multiple NICs, we can specify the IP address of the socket to open; NULL selects the default NIC.

SOCKET open_udp_socket (unsigned short * portno, const char * IPaddress) [static]

Create a UDP socket and bind it to its local address.

SOCKET open_tcp_socket (unsigned short * portno = NULL, const char * NIC_IP = NULL) [static]

Create a TCP socket and bind it to its local address.

SOCKET vrpn_connect_udp_port (const char * machineName, int remotePort, const char * NIC_IP = NULL) [static]

Create a UDP socket and connect it to a specified port.

int vrpn_udp_request_lob_packet (const char * machine, const int remote_port, const int local_port, const char * NIC_IP = NULL)

This section deals with implementing a method of connection termed a UDP request.

This works by having the client open a TCP socket that it listens on. It then lobs datagrams to the server asking to be called back at the socket. This allows it to timeout on waiting for a connection request, resend datagrams in case some got lost, or give up at any time. The whole algorithm is implemented in the vrpn_udp_request_call() function; the functions before that are helper functions that have been broken out to allow a subset of the algorithm to be run by a connection whose server has dropped and they want to re-establish it.

This routine will lob a datagram to the given port on the given machine asking it to call back at the port on this machine that is also specified. It returns 0 on success and -1 on failure.

int vrpn_get_a_TCP_socket (SOCKET * listen_sock, int * listen_portnum, const char * NIC_IP = NULL) [static]

This routine will get a TCP socket that is ready to accept connections.

That is, listen() has already been called on it. It will get whatever socket is available from the system. It returns 0 on success and -1 on failure. On success, it fills in the pointers to the socket and the port number of the socket that it obtained. To select between multiple network interfaces, we can specify an IPaddress; the default value is NULL, which uses the default NIC.

int vrpn_poll_for_accept (SOCKET listen_sock, SOCKET * accept_sock, double timeout = 0.0) [static]

This routine will check the listen socket to see if there has been a connection request.

If so, it will accept a connection on the accept socket and set TCP_NODELAY on that socket. The attempt will timeout in the amount of time specified. If the accept and set are successfull, it returns 1. If there is nothing asking for a connection, it returns 0. If there is an error along the way, it returns -1.

int vrpn_start_server (const char * machine, char * server_name, char * args, const char * IPaddress = NULL) [static]

This routine will start up a given server on a given machine.

The name of the machine requesting service and the socket number to connect to are supplied after the -client argument. The "args" parameters are passed next. They should be space-separated arguments, each of which is passed separately. It is NOT POSSIBLE to send parameters with embedded spaces. This routine returns a file descriptor that points to the socket to the server on success and -1 on failure.

int write_vrpn_cookie (char * buffer, int length, long remote_log_mode)

Writes the magic cookie into buffer with given length.

On failure (if the buffer is too short), returns -1; otherwise returns 0.

This is exposed in vrpn_Connection.h so that we can write add_vrpn_cookie.

int check_vrpn_cookie (const char * buffer)

Checks to see if the given buffer has the magic cookie.

Returns -1 on a mismatch, 0 on an exact match, 1 on a minor version difference.

int check_vrpn_file_cookie (const char * buffer)

int vrpn_cookie_size (void)

void setClockOffset (void * userdata, const vrpn_CLOCKCB & info)

int flush_udp_socket (int fd)

vrpn_Connection * vrpn_get_connection_by_name (const char * cname, const char * local_in_logfile_name, const char * local_out_logfile_name, const char * remote_in_logfile_name, const char * remote_out_logfile_name, double dFreq, int cSyncWindow, const char * NIC_IPaddress)

char * vrpn_copy_service_name (const char * fullname)

char * vrpn_copy_service_location (const char * fullname)

char * vrpn_copy_file_name (const char * filespecifier)

int header_len (const char * hostspecifier) [static]

char * vrpn_copy_machine_name (const char * hostspecifier)

int vrpn_get_port_number (const char * hostspecifier)

char * vrpn_copy_rsh_program (const char * hostspecifier)

char * vrpn_copy_rsh_arguments (const char * hostspecifier)


Variable Documentation

const char* vrpn_MAGIC

const char* vrpn_FILE_MAGIC

const int vrpn_MAGICLEN

const char* vrpn_got_first_connection

const char* vrpn_got_connection

const char* vrpn_dropped_connection

const char* vrpn_dropped_last_connection

const char* vrpn_CONTROL

vrpn_Synchronized_Connection connectionStatus


Generated at Fri Sep 13 15:03:40 2002 for vrpn by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999