vrpn
07.33
Virtual Reality Peripheral Network
|
Encapsulation of the data and methods for a single IP-based connection to take care of one part of many clients talking to a single server. More...
#include <vrpn_Connection.h>
Public Member Functions | |
vrpn_Endpoint_IP (vrpn_TypeDispatcher *dispatcher, vrpn_int32 *connectedEndpointCounter) | |
virtual | ~vrpn_Endpoint_IP (void) |
Accessors | |
virtual vrpn_bool | doing_okay (void) const |
vrpn_bool | outbound_udp_open (void) const |
True if the UDP outbound is open, False if not. More... | |
vrpn_int32 | tcp_outbuf_size (void) const |
vrpn_int32 | udp_outbuf_size (void) const |
![]() | |
vrpn_Endpoint (vrpn_TypeDispatcher *dispatcher, vrpn_int32 *connectedEndpointCounter) | |
virtual | ~vrpn_Endpoint (void) |
int | pack_log_description (void) |
Packs the log description set by setup_new_connection(). More... | |
int | pack_sender_description (vrpn_int32 which) |
Packs a sender description over our socket. More... | |
int | pack_type_description (vrpn_int32 which) |
Packs a type description. More... | |
int | local_type_id (vrpn_int32 remote_type) const |
Returns the local mapping for the remote type (-1 if none). More... | |
int | local_sender_id (vrpn_int32 remote_sender) const |
Returns the local mapping for the remote sender (-1 if none). More... | |
void | init (void) |
void | clear_other_senders_and_types (void) |
Clear out the remote mapping list. This is done when a connection is dropped and we want to try and re-establish it. More... | |
int | newLocalSender (const char *name, vrpn_int32 which) |
A new local sender or type has been established; set the local type for it if the other side has declared it. Return 1 if the other side has one, 0 if not. More... | |
int | newLocalType (const char *name, vrpn_int32 which) |
int | newRemoteType (cName type_name, vrpn_int32 remote_id, vrpn_int32 local_id) |
Adds a new remote type/sender and returns its index. Returns -1 on error. More... | |
int | newRemoteSender (cName sender_name, vrpn_int32 remote_id, vrpn_int32 local_id) |
void | setConnection (vrpn_Connection *conn) |
vrpn_Connection * | getConnection () |
void | setLogNames (const char *inName, const char *outName) |
int | openLogs (void) |
Manipulators | |
SOCKET | d_tcpSocket |
SOCKET | d_tcpListenSocket |
This section deals with when a client connection is trying to establish (or re-establish) a connection with its server. It keeps track of what we need to know to make this happen. More... | |
int | d_tcpListenPort |
Socket and port that the client listens on when lobbing datagrams at the server and waiting for it to call back. More... | |
SOCKET | d_udpLobSocket |
Socket to use to lob UDP requests asking for the server to call us back. More... | |
char * | d_remote_machine_name |
Machine to call. More... | |
int | d_remote_port_number |
Port to connect to on remote machine. More... | |
timeval | d_last_connect_attempt |
When the last UDP lob occurred. More... | |
vrpn_bool | d_tcp_only |
For connections made through firewalls or NAT with the tcp: URL, we do not want to allow the endpoints on either end to open a UDP link to their counterparts. If this is the case, then this flag should be set to true. More... | |
SOCKET | d_udpOutboundSocket |
SOCKET | d_udpInboundSocket |
Inbound unreliable messages come here. Need one for each due to different clock synchronization for each; we need to know which server each message is from. More... | |
char * | d_tcpOutbuf |
char * | d_udpOutbuf |
vrpn_int32 | d_tcpBuflen |
vrpn_int32 | d_udpBuflen |
vrpn_int32 | d_tcpNumOut |
vrpn_int32 | d_udpNumOut |
vrpn_int32 | d_tcpSequenceNumber |
vrpn_int32 | d_udpSequenceNumber |
vrpn_float64 | d_tcpAlignedInbuf [vrpn_CONNECTION_TCP_BUFLEN/sizeof(vrpn_float64)+1] |
vrpn_float64 | d_udpAlignedInbuf [vrpn_CONNECTION_UDP_BUFLEN/sizeof(vrpn_float64)+1] |
char * | d_tcpInbuf |
char * | d_udpInbuf |
char * | d_NICaddress |
void | init (void) |
int | mainloop (timeval *timeout) |
int | pack_message (vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service) |
Pack a message that will be sent the next time mainloop() is called. More... | |
virtual int | send_pending_reports (void) |
send pending report, clear the buffer. More... | |
int | pack_udp_description (int portno) |
int | handle_tcp_messages (const timeval *timeout) |
int | handle_udp_messages (const timeval *timeout) |
int | connect_tcp_to (const char *msg) |
int | connect_tcp_to (const char *addr, int port) |
Connects d_tcpSocket to the specified address (msg = "IP port"); sets status to COOKIE_PENDING; returns 0 on success, -1 on failure. More... | |
int | connect_udp_to (const char *addr, int port) |
Connects d_udpSocket to the specified address and port; returns 0 on success, sets status to BROKEN and returns -1 on failure. More... | |
vrpn_int32 | set_tcp_outbuf_size (vrpn_int32 bytecount) |
int | setup_new_connection (void) |
Sends the magic cookie and other information to its peer. It is called by both the client and server setup routines. More... | |
void | poll_for_cookie (const timeval *timeout=NULL) |
int | finish_new_connection_setup (void) |
void | drop_connection (void) |
Should only be called by vrpn_Connection::drop_connection(), since there's more housecleaning to do at that level. I suppose that argues against separating this function out. More... | |
void | clearBuffers (void) |
Empties out the TCP and UDP send buffers. Needed by vrpn_FileConnection to get at {udp,tcp}NumOut. More... | |
void | setNICaddress (const char *) |
int | getOneTCPMessage (int fd, char *buf, size_t buflen) |
int | getOneUDPMessage (char *buf, size_t buflen) |
Additional Inherited Members | |
![]() | |
static int VRPN_CALLBACK | handle_sender_message (void *userdata, vrpn_HANDLERPARAM p) |
static int VRPN_CALLBACK | handle_type_message (void *userdata, vrpn_HANDLERPARAM p) |
![]() | |
int | status |
long | d_remoteLogMode |
Mode to put the remote logging in. More... | |
char * | d_remoteInLogName |
Name of the remote log file. More... | |
char * | d_remoteOutLogName |
Name of the remote log file. More... | |
char | rhostname [150] |
vrpn_Log * | d_inLog |
vrpn_Log * | d_outLog |
![]() | |
virtual int | dispatch (vrpn_int32 type, vrpn_int32 sender, timeval time, vrpn_uint32 payload_len, char *bufptr) |
int | tryToMarshall (char *outbuf, vrpn_int32 &buflen, vrpn_int32 &numOut, vrpn_uint32 len, timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 classOfService) |
Calls marshall_message(); if that fails, calls send_pending_reports() and then marshalls again. Returns the number of characters successfully marshalled. More... | |
int | marshall_message (char *outbuf, vrpn_uint32 outbuf_size, vrpn_uint32 initial_out, vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 sequenceNumber) |
Marshal the message into the buffer if it will fit. More... | |
![]() | |
vrpn_TranslationTable * | d_senders |
vrpn_TranslationTable * | d_types |
vrpn_TypeDispatcher * | d_dispatcher |
vrpn_int32 * | d_connectionCounter |
vrpn_Connection * | d_parent |
Encapsulation of the data and methods for a single IP-based connection to take care of one part of many clients talking to a single server.
This will only be used from within the vrpn_Connection_IP class; it should not be instantiated by users or devices. Should not be visible!
Definition at line 369 of file vrpn_Connection.h.
vrpn_Endpoint_IP::vrpn_Endpoint_IP | ( | vrpn_TypeDispatcher * | dispatcher, |
vrpn_int32 * | connectedEndpointCounter | ||
) |
Definition at line 2650 of file vrpn_Connection.C.
References init().
|
virtual |
Definition at line 2707 of file vrpn_Connection.C.
References d_remote_machine_name, d_tcpListenSocket, d_tcpNumOut, d_tcpOutbuf, d_tcpSocket, d_udpInboundSocket, d_udpLobSocket, d_udpNumOut, d_udpOutboundSocket, d_udpOutbuf, INVALID_SOCKET, and vrpn_closeSocket.
|
virtual |
Empties out the TCP and UDP send buffers. Needed by vrpn_FileConnection to get at {udp,tcp}NumOut.
Implements vrpn_Endpoint.
Definition at line 3751 of file vrpn_Connection.C.
References d_tcpNumOut, and d_udpNumOut.
Referenced by drop_connection(), vrpn_File_Connection::send_pending_reports(), and send_pending_reports().
int vrpn_Endpoint_IP::connect_tcp_to | ( | const char * | addr, |
int | port | ||
) |
Connects d_tcpSocket to the specified address (msg = "IP port"); sets status to COOKIE_PENDING; returns 0 on success, -1 on failure.
Definition at line 3528 of file vrpn_Connection.C.
References d_tcpSocket.
int vrpn_Endpoint_IP::connect_tcp_to | ( | const char * | msg | ) |
Definition at line 3515 of file vrpn_Connection.C.
Referenced by vrpn_Connection_IP::connect_to_client(), mainloop(), and vrpn_Connection_IP::server_check_for_incoming_connections().
int vrpn_Endpoint_IP::connect_udp_to | ( | const char * | addr, |
int | port | ||
) |
Connects d_udpSocket to the specified address and port; returns 0 on success, sets status to BROKEN and returns -1 on failure.
Definition at line 3642 of file vrpn_Connection.C.
References d_tcp_only, and d_udpOutboundSocket.
Referenced by vrpn_Connection_IP::handle_UDP_message().
|
virtual |
Implements vrpn_Endpoint.
Definition at line 2769 of file vrpn_Connection.C.
References LOGGING, vrpn_Endpoint::status, and TRYING_TO_CONNECT.
Referenced by poll_for_cookie().
|
virtual |
Should only be called by vrpn_Connection::drop_connection(), since there's more housecleaning to do at that level. I suppose that argues against separating this function out.
Implements vrpn_Endpoint.
Definition at line 3680 of file vrpn_Connection.C.
References vrpn_Endpoint::clear_other_senders_and_types(), clearBuffers(), vrpn_Log::close(), vrpn_Endpoint::d_connectionCounter, vrpn_Endpoint::d_dispatcher, vrpn_Endpoint::d_outLog, d_tcpNumOut, d_tcpSocket, d_udpInboundSocket, d_udpNumOut, d_udpOutboundSocket, INVALID_SOCKET, vrpn_Log::logMessage(), vrpn_Log::logMode(), vrpn_closeSocket, vrpn_CONNECTION_DISCONNECT_MESSAGE, vrpn_CONTROL, vrpn_dropped_connection, vrpn_dropped_last_connection, and vrpn_gettimeofday.
Referenced by vrpn_File_Connection::reset(), and vrpn_Connection_IP::~vrpn_Connection_IP().
|
virtual |
Implements vrpn_Endpoint.
Definition at line 3873 of file vrpn_Connection.C.
References BROKEN, check_vrpn_cookie(), CONNECTED, vrpn_Endpoint::d_inLog, vrpn_Endpoint::d_outLog, d_tcp_only, d_tcpSocket, d_udpInboundSocket, INVALID_SOCKET, vrpn_Log::logMode(), vrpn_Endpoint::pack_log_description(), vrpn_Log::setCookie(), vrpn_Endpoint::status, vrpn_cookie_size(), vrpn_LOG_INCOMING, vrpn_LOG_OUTGOING, vrpn_MAGICLEN, and vrpn_noint_block_read().
Referenced by poll_for_cookie().
|
protected |
Definition at line 4020 of file vrpn_Connection.C.
References vrpn_noint_block_read().
Referenced by handle_tcp_messages().
|
protected |
Definition at line 4105 of file vrpn_Connection.C.
Referenced by handle_udp_messages().
int vrpn_Endpoint_IP::handle_tcp_messages | ( | const timeval * | timeout | ) |
Definition at line 3336 of file vrpn_Connection.C.
References vrpn_Endpoint::d_parent, d_tcpAlignedInbuf, d_tcpInbuf, d_tcpSocket, vrpn_Connection::get_Jane_value(), getOneTCPMessage(), and vrpn_noint_select().
Referenced by mainloop().
int vrpn_Endpoint_IP::handle_udp_messages | ( | const timeval * | timeout | ) |
Definition at line 3421 of file vrpn_Connection.C.
References vrpn_Endpoint::d_parent, d_udpAlignedInbuf, d_udpInboundSocket, d_udpInbuf, vrpn_Connection::get_Jane_value(), getOneUDPMessage(), and vrpn_noint_select().
Referenced by mainloop().
void vrpn_Endpoint_IP::init | ( | void | ) |
Definition at line 2803 of file vrpn_Connection.C.
References d_last_connect_attempt, d_tcpListenPort, d_tcpListenSocket, d_tcpSocket, d_udpInboundSocket, d_udpLobSocket, d_udpOutboundSocket, and INVALID_SOCKET.
Referenced by vrpn_Endpoint_IP().
|
virtual |
Implements vrpn_Endpoint.
Definition at line 2817 of file vrpn_Connection.C.
References BROKEN, connect_tcp_to(), CONNECTED, COOKIE_PENDING, d_last_connect_attempt, d_remote_machine_name, d_remote_port_number, d_tcp_only, d_tcpSocket, d_udpInboundSocket, handle_tcp_messages(), handle_udp_messages(), poll_for_cookie(), send_pending_reports(), setup_new_connection(), vrpn_Endpoint::status, TRYING_TO_CONNECT, vrpn_gettimeofday, and vrpn_noint_select().
vrpn_bool vrpn_Endpoint_IP::outbound_udp_open | ( | void | ) | const |
True if the UDP outbound is open, False if not.
Definition at line 2750 of file vrpn_Connection.C.
References d_udpOutboundSocket.
|
virtual |
Pack a message that will be sent the next time mainloop() is called.
Pack a message into the appropriate output buffer (TCP or UDP) depending on the class of service for the message, and handle logging for the message (but not filtering).
Turn off the RELIABLE flag if you want low-latency (UDP) send.
This function does not handle semantic checking, local callbacks and filtering. (these must be done in the vrpn_Connection class routine that calls this one).
Parameters: The length of the message, the local-clock time value for the message, the type and sender IDs for the message, the buffer that holds the message contents, and the class of service (currently, only reliable/unreliable is used).
Returns 0 on success and -1 on failure.
Implements vrpn_Endpoint.
Definition at line 3075 of file vrpn_Connection.C.
References CONNECTED, vrpn_Endpoint::d_outLog, d_tcpBuflen, d_tcpNumOut, d_tcpOutbuf, d_tcpSequenceNumber, d_tcpSocket, d_udpBuflen, d_udpNumOut, d_udpOutboundSocket, d_udpOutbuf, d_udpSequenceNumber, LOGGING, vrpn_Log::logOutgoingMessage(), vrpn_Endpoint::status, vrpn_Endpoint::tryToMarshall(), and vrpn_CONNECTION_RELIABLE.
int vrpn_Endpoint_IP::pack_udp_description | ( | int | portno | ) |
Definition at line 3239 of file vrpn_Connection.C.
References d_NICaddress.
|
virtual |
Implements vrpn_Endpoint.
Definition at line 3811 of file vrpn_Connection.C.
References BROKEN, CONNECTED, d_remote_machine_name, d_tcpSocket, doing_okay(), finish_new_connection_setup(), vrpn_Endpoint::status, and vrpn_noint_select().
Referenced by mainloop(), and setup_new_connection().
|
virtual |
send pending report, clear the buffer.
This function was protected, now is public, so we can use it to send out intermediate results without calling mainloop
Implements vrpn_Endpoint.
Definition at line 3143 of file vrpn_Connection.C.
References BROKEN, clearBuffers(), d_tcpNumOut, d_tcpOutbuf, d_tcpSocket, d_udpNumOut, d_udpOutboundSocket, d_udpOutbuf, vrpn_Endpoint::status, and vrpn_noint_select().
Referenced by mainloop().
vrpn_int32 vrpn_Endpoint_IP::set_tcp_outbuf_size | ( | vrpn_int32 | bytecount | ) |
Definition at line 3656 of file vrpn_Connection.C.
References d_tcpBuflen, and d_tcpOutbuf.
void vrpn_Endpoint_IP::setNICaddress | ( | const char * | address | ) |
Definition at line 3757 of file vrpn_Connection.C.
References d_NICaddress.
Referenced by vrpn_Connection_IP::server_check_for_incoming_connections(), and vrpn_Connection_IP::vrpn_Connection_IP().
|
virtual |
Sends the magic cookie and other information to its peer. It is called by both the client and server setup routines.
Implements vrpn_Endpoint.
Definition at line 3779 of file vrpn_Connection.C.
References BROKEN, COOKIE_PENDING, vrpn_Endpoint::d_remoteLogMode, d_tcpSocket, poll_for_cookie(), vrpn_Endpoint::status, vrpn_cookie_size(), vrpn_noint_block_write(), and write_vrpn_cookie().
Referenced by mainloop().
vrpn_int32 vrpn_Endpoint_IP::tcp_outbuf_size | ( | void | ) | const |
Definition at line 2765 of file vrpn_Connection.C.
References d_tcpBuflen.
vrpn_int32 vrpn_Endpoint_IP::udp_outbuf_size | ( | void | ) | const |
Definition at line 2767 of file vrpn_Connection.C.
References d_udpBuflen.
timeval vrpn_Endpoint_IP::d_last_connect_attempt |
When the last UDP lob occurred.
Definition at line 464 of file vrpn_Connection.h.
Referenced by init(), and mainloop().
|
protected |
Definition at line 503 of file vrpn_Connection.h.
Referenced by pack_udp_description(), and setNICaddress().
char* vrpn_Endpoint_IP::d_remote_machine_name |
Machine to call.
Definition at line 462 of file vrpn_Connection.h.
Referenced by mainloop(), poll_for_cookie(), vrpn_Connection_IP::server_check_for_incoming_connections(), vrpn_Connection_IP::vrpn_Connection_IP(), and ~vrpn_Endpoint_IP().
int vrpn_Endpoint_IP::d_remote_port_number |
Port to connect to on remote machine.
Definition at line 463 of file vrpn_Connection.h.
Referenced by mainloop(), and vrpn_Connection_IP::vrpn_Connection_IP().
vrpn_bool vrpn_Endpoint_IP::d_tcp_only |
For connections made through firewalls or NAT with the tcp: URL, we do not want to allow the endpoints on either end to open a UDP link to their counterparts. If this is the case, then this flag should be set to true.
Definition at line 466 of file vrpn_Connection.h.
Referenced by connect_udp_to(), finish_new_connection_setup(), and mainloop().
|
protected |
Definition at line 496 of file vrpn_Connection.h.
Referenced by handle_tcp_messages().
|
protected |
Definition at line 486 of file vrpn_Connection.h.
Referenced by pack_message(), set_tcp_outbuf_size(), and tcp_outbuf_size().
|
protected |
Definition at line 500 of file vrpn_Connection.h.
Referenced by handle_tcp_messages().
int vrpn_Endpoint_IP::d_tcpListenPort |
Socket and port that the client listens on when lobbing datagrams at the server and waiting for it to call back.
Definition at line 453 of file vrpn_Connection.h.
Referenced by init().
SOCKET vrpn_Endpoint_IP::d_tcpListenSocket |
This section deals with when a client connection is trying to establish (or re-establish) a connection with its server. It keeps track of what we need to know to make this happen.
Definition at line 452 of file vrpn_Connection.h.
Referenced by init(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 488 of file vrpn_Connection.h.
Referenced by clearBuffers(), drop_connection(), pack_message(), send_pending_reports(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 484 of file vrpn_Connection.h.
Referenced by pack_message(), send_pending_reports(), set_tcp_outbuf_size(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 491 of file vrpn_Connection.h.
Referenced by pack_message().
SOCKET vrpn_Endpoint_IP::d_tcpSocket |
Definition at line 446 of file vrpn_Connection.h.
Referenced by connect_tcp_to(), drop_connection(), finish_new_connection_setup(), handle_tcp_messages(), init(), mainloop(), pack_message(), poll_for_cookie(), send_pending_reports(), setup_new_connection(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 499 of file vrpn_Connection.h.
Referenced by handle_udp_messages().
|
protected |
Definition at line 487 of file vrpn_Connection.h.
Referenced by pack_message(), and udp_outbuf_size().
|
protected |
Inbound unreliable messages come here. Need one for each due to different clock synchronization for each; we need to know which server each message is from.
Definition at line 477 of file vrpn_Connection.h.
Referenced by drop_connection(), finish_new_connection_setup(), handle_udp_messages(), init(), mainloop(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 501 of file vrpn_Connection.h.
Referenced by handle_udp_messages().
SOCKET vrpn_Endpoint_IP::d_udpLobSocket |
Socket to use to lob UDP requests asking for the server to call us back.
Definition at line 460 of file vrpn_Connection.h.
Referenced by init(), vrpn_Connection_IP::vrpn_Connection_IP(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 489 of file vrpn_Connection.h.
Referenced by clearBuffers(), drop_connection(), pack_message(), send_pending_reports(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 476 of file vrpn_Connection.h.
Referenced by connect_udp_to(), drop_connection(), init(), outbound_udp_open(), pack_message(), send_pending_reports(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 485 of file vrpn_Connection.h.
Referenced by pack_message(), send_pending_reports(), and ~vrpn_Endpoint_IP().
|
protected |
Definition at line 492 of file vrpn_Connection.h.
Referenced by pack_message().