vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Connection.h
Go to the documentation of this file.
1 #ifndef VRPN_CONNECTION_H
2 #define VRPN_CONNECTION_H
3 
4 #include <stdio.h> // for NULL, sprintf
5 
6 #include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK, etc
7 #include "vrpn_Shared.h" // for SOCKET, timeval
8 #include "vrpn_Types.h" // for vrpn_int32, vrpn_uint32, etc
9 
10 #if !(defined(_WIN32) && defined(VRPN_USE_WINSOCK_SOCKETS))
11 #include <sys/select.h> // for fd_set
12 #endif
13 
14 struct timeval;
15 
16 // Don't complain about using sprintf() when using Visual Studio.
17 #ifdef _MSC_VER
18 #pragma warning(disable : 4995 4996)
19 #endif
20 
21 #if defined(__ANDROID__)
22 #include <bitset>
23 #endif
24 
29  LISTEN = (1),
30  CONNECTED = (0),
33  BROKEN = (-3),
34  LOGGING = (-4)
35 };
36 
37 class VRPN_API
38  vrpn_File_Connection; // Forward declaration for get_File_Connection()
39 
45  vrpn_int32 type;
46  vrpn_int32 sender;
47  struct timeval msg_time;
48  vrpn_int32 payload_len;
49  const char *buffer;
50 };
51 
53 typedef int(VRPN_CALLBACK *vrpn_MESSAGEHANDLER)(void *userdata,
55 
59 
63 const unsigned vrpn_ALIGN = 8;
64 
70 const int vrpn_CONNECTION_MAX_SENDERS = 2000;
71 const int vrpn_CONNECTION_MAX_TYPES = 2000;
73 
76 
77 const int vrpn_ANY_SENDER = -1;
78 
81 
82 const int vrpn_ANY_TYPE = -1;
83 
94 
95 const int vrpn_CONNECTION_TCP_BUFLEN = 64000;
96 const int vrpn_CONNECTION_UDP_BUFLEN = 1472;
98 
101 
102 const int vrpn_MAX_ENDPOINTS = 256;
103 
106 const vrpn_int32 vrpn_CONNECTION_SENDER_DESCRIPTION = (-1);
107 const vrpn_int32 vrpn_CONNECTION_TYPE_DESCRIPTION = (-2);
108 const vrpn_int32 vrpn_CONNECTION_UDP_DESCRIPTION = (-3);
109 const vrpn_int32 vrpn_CONNECTION_LOG_DESCRIPTION = (-4);
110 const vrpn_int32 vrpn_CONNECTION_DISCONNECT_MESSAGE = (-5);
112 
119 
120 const vrpn_uint32 vrpn_CONNECTION_RELIABLE = (1 << 0);
121 const vrpn_uint32 vrpn_CONNECTION_FIXED_LATENCY = (1 << 1);
122 const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY = (1 << 2);
123 const vrpn_uint32 vrpn_CONNECTION_FIXED_THROUGHPUT = (1 << 3);
124 const vrpn_uint32 vrpn_CONNECTION_HIGH_THROUGHPUT = (1 << 4);
125 
127 
130 const long vrpn_LOG_NONE = (0);
131 const long vrpn_LOG_INCOMING = (1 << 0);
132 const long vrpn_LOG_OUTGOING = (1 << 1);
134 
135 // If defined, will filter out messages: if the remote side hasn't
136 // registered a type, messages of that type won't be sent over the
137 // link. WARNING: auto-type-registration breaks this.
138 //#define vrpn_FILTER_MESSAGES
139 
143 extern VRPN_API const char *vrpn_got_first_connection;
144 extern VRPN_API const char *vrpn_got_connection;
145 extern VRPN_API const char *vrpn_dropped_connection;
146 extern VRPN_API const char *vrpn_dropped_last_connection;
148 
154 
155 extern VRPN_API const char *vrpn_CONTROL;
156 
158 typedef char cName[100];
159 
165 };
166 
172 
176  void *userdata;
177  vrpn_int32 sender;
179 };
180 
183  void *userdata;
185 };
187 
192 
199 
201 
202 public:
204  vrpn_int32 *connectedEndpointCounter);
205  virtual ~vrpn_Endpoint(void);
206 
209 
211  int local_type_id(vrpn_int32 remote_type) const;
212 
214  int local_sender_id(vrpn_int32 remote_sender) const;
215 
216  virtual vrpn_bool doing_okay(void) const = 0;
218 
221 
222  void init(void);
223 
224  virtual int mainloop(timeval *timeout) = 0;
225 
229  void clear_other_senders_and_types(void);
230 
234  int newLocalSender(const char *name, vrpn_int32 which);
235  int newLocalType(const char *name, vrpn_int32 which);
236 
240  int newRemoteType(cName type_name, vrpn_int32 remote_id,
241  vrpn_int32 local_id);
242  int newRemoteSender(cName sender_name, vrpn_int32 remote_id,
243  vrpn_int32 local_id);
245 
248  virtual int pack_message(vrpn_uint32 len, struct timeval time,
249  vrpn_int32 type, vrpn_int32 sender,
250  const char *buffer,
251  vrpn_uint32 class_of_service) = 0;
252 
256  virtual int send_pending_reports(void) = 0;
257 
258  int pack_log_description(void);
260 
261  virtual int setup_new_connection(void) = 0;
264 
265  virtual void poll_for_cookie(const timeval *timeout = NULL) = 0;
266  virtual int finish_new_connection_setup(void) = 0;
267 
268  virtual void drop_connection(void) = 0;
272 
273  virtual void clearBuffers(void) = 0;
276 
277  int pack_sender_description(vrpn_int32 which);
279 
280  int pack_type_description(vrpn_int32 which);
282 
284  int status;
285 
289 
293 
297  char rhostname[150];
298 
303 
306 
307  void setLogNames(const char *inName, const char *outName);
308  int openLogs(void);
310 
315  static int VRPN_CALLBACK
316  handle_sender_message(void *userdata, vrpn_HANDLERPARAM p);
317  static int VRPN_CALLBACK
318  handle_type_message(void *userdata, vrpn_HANDLERPARAM p);
320 
324  void setConnection(vrpn_Connection *conn) { d_parent = conn; }
325  vrpn_Connection *getConnection() { return d_parent; }
327 
328 protected:
329  virtual int dispatch(vrpn_int32 type, vrpn_int32 sender, timeval time,
330  vrpn_uint32 payload_len, char *bufptr);
331 
332  int tryToMarshall(char *outbuf, vrpn_int32 &buflen, vrpn_int32 &numOut,
333  vrpn_uint32 len, timeval time, vrpn_int32 type,
334  vrpn_int32 sender, const char *buffer,
335  vrpn_uint32 classOfService);
339 
340  int marshall_message(char *outbuf, vrpn_uint32 outbuf_size,
341  vrpn_uint32 initial_out, vrpn_uint32 len,
342  struct timeval time, vrpn_int32 type,
343  vrpn_int32 sender, const char *buffer,
344  vrpn_uint32 sequenceNumber);
345 
346  // The senders and types we know about that have been described by
347  // the other end of the connection. Also, record the local mapping
348  // for ones that have been described with the same name locally.
349  // The arrays are indexed by the ID from the other side, and store
350  // the name and local ID that corresponds to each.
351 
354 
356  vrpn_int32 *d_connectionCounter;
357 
359 };
360 
368 
370 
371 public:
373  vrpn_int32 *connectedEndpointCounter);
374  virtual ~vrpn_Endpoint_IP(void);
375 
378  virtual vrpn_bool doing_okay(void) const;
379 
381  vrpn_bool outbound_udp_open(void) const;
382 
383  vrpn_int32 tcp_outbuf_size(void) const;
384  vrpn_int32 udp_outbuf_size(void) const;
386 
389 
390  void init(void);
391 
392  int mainloop(timeval *timeout);
393 
398  int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type,
399  vrpn_int32 sender, const char *buffer,
400  vrpn_uint32 class_of_service);
401 
406  virtual int send_pending_reports(void);
407 
408  int pack_udp_description(int portno);
409 
410  int handle_tcp_messages(const timeval *timeout);
411  int handle_udp_messages(const timeval *timeout);
412 
413  int connect_tcp_to(const char *msg);
414  int connect_tcp_to(const char *addr, int port);
417  int connect_udp_to(const char *addr, int port);
421 
422  vrpn_int32 set_tcp_outbuf_size(vrpn_int32 bytecount);
423 
424  int setup_new_connection(void);
427 
428  void poll_for_cookie(const timeval *timeout = NULL);
429  int finish_new_connection_setup(void);
430 
431  void drop_connection(void);
435 
436  void clearBuffers(void);
439 
440  void setNICaddress(const char *);
441 
445 
447 
451 
457 
461 
465 
466  vrpn_bool d_tcp_only;
471 
472 protected:
473  int getOneTCPMessage(int fd, char *buf, size_t buflen);
474  int getOneUDPMessage(char *buf, size_t buflen);
475 
483 
484  char *d_tcpOutbuf;
485  char *d_udpOutbuf;
486  vrpn_int32 d_tcpBuflen;
487  vrpn_int32 d_udpBuflen;
488  vrpn_int32 d_tcpNumOut;
489  vrpn_int32 d_udpNumOut;
490 
493 
494  vrpn_float64
495  d_tcpAlignedInbuf[vrpn_CONNECTION_TCP_BUFLEN / sizeof(vrpn_float64) +
496  1];
497  vrpn_float64
498  d_udpAlignedInbuf[vrpn_CONNECTION_UDP_BUFLEN / sizeof(vrpn_float64) +
499  1];
500  char *d_tcpInbuf;
501  char *d_udpInbuf;
502 
504 };
505 
511 
512 protected:
517  vrpn_Connection(const char *local_in_logfile_name,
518  const char *local_out_logfile_name,
520  vrpn_int32 *) = allocateEndpoint);
521 
525  vrpn_Connection(const char *local_in_logfile_name,
526  const char *local_out_logfile_name,
527  const char *remote_in_logfile_name,
528  const char *remote_out_logfile_name,
530  vrpn_int32 *) = allocateEndpoint);
531 
532 public:
533  virtual ~vrpn_Connection(void);
534 
536  virtual vrpn_bool doing_okay(void) const;
537 
540  virtual vrpn_bool connected(void) const;
541 
548  void get_log_names(char **local_in_logname, char **local_out_logname,
549  char **remote_in_logname, char **remote_out_logname);
550 
558  virtual int mainloop(const struct timeval *timeout = NULL) = 0;
559 
562  virtual vrpn_int32 register_sender(const char *name);
563  virtual vrpn_int32 register_message_type(const char *name);
564 
570  virtual int register_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler,
571  void *userdata,
572  vrpn_int32 sender = vrpn_ANY_SENDER);
573  virtual int unregister_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler,
574  void *userdata,
575  vrpn_int32 sender = vrpn_ANY_SENDER);
576 
579  virtual int pack_message(vrpn_uint32 len, struct timeval time,
580  vrpn_int32 type, vrpn_int32 sender,
581  const char *buffer, vrpn_uint32 class_of_service);
582 
586  virtual int send_pending_reports(void) = 0;
587 
590  virtual int time_since_connection_open(struct timeval *elapsed_time);
591 
594  virtual timeval get_time();
595 
599  virtual const char *sender_name(vrpn_int32 sender);
600  virtual const char *message_type_name(vrpn_int32 type);
601 
609  virtual int register_log_filter(vrpn_LOGFILTER filter, void *userdata);
610 
612  virtual int save_log_so_far();
613 
616  virtual vrpn_File_Connection *get_File_Connection(void);
617 
638  void Jane_stop_this_crazy_thing(vrpn_uint32 stop_looking_after)
639  {
640  d_stop_processing_messages_after = stop_looking_after;
641  };
642  vrpn_uint32 get_Jane_value(void)
643  {
644  return d_stop_processing_messages_after;
645  };
646 
647 protected:
651  vrpn_uint32 d_stop_processing_messages_after;
652 
654 
655  static vrpn_Endpoint_IP *allocateEndpoint(vrpn_Connection *,
656  vrpn_int32 *connectedEC);
662 
666  vrpn_int32 d_numEndpoints;
667 
673 
676  static int VRPN_CALLBACK
677  handle_log_message(void *userdata, vrpn_HANDLERPARAM p);
678  static int VRPN_CALLBACK
679  handle_disconnect_message(void *userdata, vrpn_HANDLERPARAM p);
681 
682  virtual void init(void);
683 
684  int delete_endpoint(int whichEndpoint);
685  int compact_endpoints(void);
686 
687  virtual int pack_sender_description(vrpn_int32 which);
689 
690  virtual int pack_type_description(vrpn_int32 which);
692 
693  virtual int do_callbacks_for(vrpn_int32 type, vrpn_int32 sender,
694  struct timeval time, vrpn_uint32 len,
695  const char *buffer);
696 
698  int message_type_is_registered(const char *) const;
699 
701  timeval start_time;
702 
703  //
705 public:
706  void addReference();
707  void removeReference();
708 
709 private:
710  int d_references;
711 
712  //
723 public:
724  void setAutoDeleteStatus(bool setvalue) { d_autoDeleteStatus = setvalue; }
725 
726 private:
727  bool d_autoDeleteStatus;
728 
729 public:
734 
736 
737 protected:
738  int doSystemCallbacksFor(vrpn_HANDLERPARAM, void *);
739 
748 
749  // vrpn_Endpoint * d_serverLogEndpoint;
751  vrpn_int32 d_serverLogMode;
753 
754  vrpn_Endpoint_IP *(*d_endpointAllocator)(vrpn_Connection *, vrpn_int32 *);
755  vrpn_bool d_updateEndpoint;
756 
757  virtual void updateEndpoints(void);
763 };
764 
766 
767 protected:
779  vrpn_Connection_IP(const char *server_name,
780  int port = vrpn_DEFAULT_LISTEN_PORT_NO,
781  const char *local_in_logfile_name = NULL,
782  const char *local_out_logfile_name = NULL,
783  const char *remote_in_logfile_name = NULL,
784  const char *remote_out_logfile_name = NULL,
785  const char *NIC_IPaddress = NULL,
786  vrpn_Endpoint_IP *(*epa)(
787  vrpn_Connection *, vrpn_int32 *) = allocateEndpoint);
788 
789 public:
794  unsigned short listen_port_no = vrpn_DEFAULT_LISTEN_PORT_NO,
795  const char *local_in_logfile_name = NULL,
796  const char *local_out_logfile_name = NULL,
797  const char *NIC_IPaddress = NULL,
799  vrpn_int32 *) = allocateEndpoint);
800 
801  virtual ~vrpn_Connection_IP(void);
802 
805  virtual int connect_to_client(const char *machine, int port);
806 
814  virtual int mainloop(const struct timeval *timeout = NULL);
815 
816 protected:
821 
822 protected:
824  const char *cname, const char *local_in_logfile_name,
825  const char *local_out_logfile_name, const char *remote_in_logfile_name,
826  const char *remote_out_logfile_name, const char *NIC_IPaddress,
827  bool force_connection);
828  friend VRPN_API vrpn_Connection *
829  vrpn_create_server_connection(const char *cname,
830  const char *local_in_logfile_name,
831  const char *local_out_logfile_name);
832 
837 
840  static int VRPN_CALLBACK
841  handle_UDP_message(void *userdata, vrpn_HANDLERPARAM p);
842 
844  virtual void init(void);
845 
850  virtual int send_pending_reports(void);
851 
855  virtual void
856  server_check_for_incoming_connections(const struct timeval *timeout = NULL);
857 
861  virtual void handle_connection(int whichEndpoint);
862 
863  virtual void drop_connection(int whichEndpoint);
864 
865  char *d_NIC_IP;
866 };
867 
873 
875 
876 protected:
882 public:
883  virtual ~vrpn_Connection_Loopback(void);
884 
891  virtual int mainloop(const struct timeval *timeout = NULL);
892 
894  virtual vrpn_bool doing_okay(void) const { return vrpn_true; }
895 
898  virtual vrpn_bool connected(void) const { return vrpn_true; }
899 
900 protected:
901  friend VRPN_API vrpn_Connection *
902  vrpn_create_server_connection(const char *cname,
903  const char *local_in_logfile_name,
904  const char *local_out_logfile_name);
905 
910  virtual int send_pending_reports(void) {return 0;}
911 };
912 
923  const char *cname, const char *local_in_logfile_name = NULL,
924  const char *local_out_logfile_name = NULL,
925  const char *remote_in_logfile_name = NULL,
926  const char *remote_out_logfile_name = NULL,
927  const char *NIC_IPaddress = NULL, bool force_reopen = false);
928 
946 vrpn_create_server_connection(const char *cname,
947  const char *local_in_logfile_name = NULL,
948  const char *local_out_logfile_name = NULL);
949 
954 inline VRPN_API vrpn_Connection *
956  const char *local_in_logfile_name = NULL,
957  const char *local_out_logfile_name = NULL,
958  const char *NIC_NAME = NULL)
959 {
960  char name[256];
961  if (NIC_NAME == NULL) {
962  sprintf(name, ":%d", port);
963  }
964  else {
965  sprintf(name, "%s:%d", NIC_NAME, port);
966  }
967  return vrpn_create_server_connection(name, local_in_logfile_name,
968  local_out_logfile_name);
969 }
970 
975 VRPN_API char *vrpn_copy_service_name(const char *fullname);
976 VRPN_API char *vrpn_copy_service_location(const char *fullname);
978 
986 VRPN_API char *vrpn_copy_file_name(const char *filespecifier);
987 
1003 VRPN_API char *vrpn_copy_machine_name(const char *hostspecifier);
1004 VRPN_API int vrpn_get_port_number(const char *hostspecifier);
1005 VRPN_API char *vrpn_copy_rsh_program(const char *hostspecifier);
1006 VRPN_API char *vrpn_copy_rsh_arguments(const char *hostspecifier);
1008 
1010 char *vrpn_set_service_name(const char *specifier, const char *newServiceName);
1011 
1017 VRPN_API int check_vrpn_cookie(const char *buffer);
1018 VRPN_API int check_vrpn_file_cookie(const char *buffer);
1020 
1023 VRPN_API size_t vrpn_cookie_size(void);
1024 
1025 VRPN_API int write_vrpn_cookie(char *buffer, size_t length,
1026  long remote_log_mode);
1027 
1031 #ifndef VRPN_USE_WINSOCK_SOCKETS
1032 int VRPN_API
1033 vrpn_noint_block_write(int outfile, const char buffer[], size_t length);
1034 int VRPN_API vrpn_noint_block_read(int infile, char buffer[], size_t length);
1035 int VRPN_API vrpn_noint_select(int width, fd_set *readfds, fd_set *writefds,
1036  fd_set *exceptfds, struct timeval *timeout);
1037 #else /* winsock sockets */
1038 int VRPN_API
1039 vrpn_noint_block_write(SOCKET outsock, char *buffer, size_t length);
1040 int VRPN_API vrpn_noint_block_read(SOCKET insock, char *buffer, size_t length);
1041 #endif /* VRPN_USE_WINSOCK_SOCKETS */
1042 
1056 // This section holds data structures and functions to open
1057 // connections by name.
1058 // The intention of this section is that it can open connections for
1059 // objects that are in different libraries (trackers, buttons and sound),
1060 // even if they all refer to the same connection.
1061 
1063 
1064 public:
1065  ~vrpn_ConnectionManager(void);
1066 
1072  static vrpn_ConnectionManager &instance(void);
1073 
1077  void addConnection(vrpn_Connection *, const char *name);
1078  void deleteConnection(vrpn_Connection *);
1080 
1083  vrpn_Connection *getByName(const char *name);
1084 
1085 private:
1086  struct knownConnection {
1087  char name[1000];
1088  vrpn_Connection *connection;
1089  knownConnection *next;
1090  };
1091 
1093  knownConnection *d_kcList;
1094 
1096  knownConnection *d_anonList;
1097 
1098  vrpn_ConnectionManager(void);
1099 
1100  // @brief copy constructor undefined to prevent instantiations
1102 
1103  static void deleteConnection(vrpn_Connection *, knownConnection **);
1104 };
1105 
1106 #endif // VRPN_CONNECTION_H
virtual int mainloop(const struct timeval *timeout=NULL)=0
Call each time through program main loop to handle receiving any incoming messages and sending any pa...
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
const int vrpn_ANY_TYPE
vrpn_ANY_TYPE can be used to register callbacks for any USER type of message from a given sender...
vrpn_int32 d_numEndpoints
const vrpn_uint32 vrpn_CONNECTION_FIXED_THROUGHPUT
char * vrpn_set_service_name(const char *specifier, const char *newServiceName)
Utility routine to rename the service name of a given host specifier.
void * userdata
passed along
struct timeval msg_time
vrpn_uint32 get_Jane_value(void)
char * d_remoteOutLogName
Name of the remote log file.
virtual int mainloop(timeval *timeout)=0
int d_tcpListenPort
Socket and port that the client listens on when lobbing datagrams at the server and waiting for it to...
VRPN_API vrpn_Connection * vrpn_get_connection_by_name(const char *cname, const char *local_in_logfile_name=NULL, const char *local_out_logfile_name=NULL, const char *remote_in_logfile_name=NULL, const char *remote_out_logfile_name=NULL, const char *NIC_IPaddress=NULL, bool force_reopen=false)
Create a client connection of arbitrary type (VRPN UDP/TCP, TCP, File, Loopback, MPI).
class VRPN_API vrpn_Connection
Logs a VRPN stream.
Definition: vrpn_Log.h:10
vrpn_int32 d_serverLogMode
int VRPN_API vrpn_noint_block_read(int infile, char buffer[], size_t length)
This routine will read in a block from the file descriptor.
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
int VRPN_API 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 i...
vrpn_LOGLIST * prev
Encapsulation of the data and methods for a single IP-based connection to take care of one part of ma...
vrpn_int32 payload_len
virtual int send_pending_reports(void)
send pending report, clear the buffer.
VRPN_API const char * vrpn_got_first_connection
These are the strings that define the system-generated message types that tell when connections are r...
vrpn_uint32 d_stop_processing_messages_after
If this value is greater than zero, the connection should stop looking for new messages on a given en...
Description of a callback entry for a user type.
vrpn_Log * d_outLog
VRPN_API int vrpn_get_port_number(const char *hostspecifier)
int d_remote_port_number
Port to connect to on remote machine.
const vrpn_int32 vrpn_CONNECTION_UDP_DESCRIPTION
virtual int finish_new_connection_setup(void)=0
virtual int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)=0
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if yo...
VRPN_API const char * vrpn_got_connection
const char * buffer
vrpn_Connection * d_parent
const vrpn_int32 vrpn_CONNECTION_SENDER_DESCRIPTION
virtual int send_pending_reports(void)=0
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
VRPN_API const char * vrpn_dropped_last_connection
const vrpn_int32 vrpn_CONNECTION_DISCONNECT_MESSAGE
void Jane_stop_this_crazy_thing(vrpn_uint32 stop_looking_after)
This function should be seldom used. It is here for the case of the vrpn_Imager, whose servers do not...
Generic connection class not specific to the transport mechanism.
char * d_remote_machine_name
Machine to call.
const unsigned vrpn_ALIGN
VRPN buffers are aligned on 8 byte boundaries so that we can pack and unpack doubles into them on arc...
virtual void clearBuffers(void)=0
Empties out the TCP and UDP send buffers. Needed by vrpn_FileConnection to get at {udp...
VRPN_API size_t vrpn_cookie_size(void)
Returns the size of the magic cookie buffer, plus any alignment overhead.
vrpn_MESSAGEHANDLER handler
Routine to call.
vrpn_int32 d_udpBuflen
#define VRPN_CALLBACK
int(VRPN_CALLBACK * vrpn_MESSAGEHANDLER)(void *userdata, vrpn_HANDLERPARAM p)
Type of a message handler for vrpn_Connection messages.
VRPN_API const char * vrpn_dropped_connection
#define VRPN_API
vrpn_LOGFILTER filter
routine to call
const vrpn_int32 vrpn_CONNECTION_LOG_DESCRIPTION
VRPN_API int check_vrpn_file_cookie(const char *buffer)
virtual int send_pending_reports(void)=0
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
Constructor for a Loopback connection that will basically just pass messages between objects that are...
vrpn_int32 d_udpSequenceNumber
const long vrpn_LOG_OUTGOING
const vrpn_int32 vrpn_CONNECTION_TYPE_DESCRIPTION
SOCKET listen_tcp_sock
TCP Connection requests come here.
VRPN_API char * vrpn_copy_file_name(const char *filespecifier)
Utility routines to parse file specifiers FROM service locations.
VRPN_API const char * vrpn_CONTROL
vrpn_CONTROL is the sender used for notification messages sent to the user from the local VRPN implem...
vrpn_int32 d_tcpSequenceNumber
vrpn_Connection * getConnection()
char cName[100]
Length of names within VRPN.
void setConnection(vrpn_Connection *conn)
vrpnLogFilterEntry * next
This structure is what is passed to a vrpn_Connection message callback.
void setAutoDeleteStatus(bool setvalue)
Specify whether this connection should be deleted automatically when it is no longer need (reference ...
vrpn_ConnectionStatus
This is the list of states that a connection can be in (possible values for status). doing_okay() returns VRPN_TRUE for connections > BROKEN.
virtual void init(void)
Base initialization for all constructors.
Singleton class that keeps track of all known VRPN connections and makes sure they&#39;re deleted on shut...
class VRPN_API vrpn_TranslationTable
int connectionStatus
Status of the connection.
virtual int setup_new_connection(void)=0
Sends the magic cookie and other information to its peer. It is called by both the client and server ...
void * userdata
Passed along.
VRPN_API char * vrpn_copy_service_location(const char *fullname)
vrpn_int32 sender
Only if from sender.
timeval start_time
Timekeeping - TCH 30 June 98.
const long vrpn_LOG_NONE
char * d_remoteInLogName
Name of the remote log file.
vrpn_MESSAGEHANDLER vrpn_LOGFILTER
Type of handler for filters on logfiles is the same as connection handler.
vrpn_int32 d_tcpNumOut
int VRPN_API vrpn_noint_block_write(int outfile, const char buffer[], size_t length)
This routine will write a block to a file descriptor.
long d_remoteLogMode
Mode to put the remote logging in.
Encapsulation of the data and methods for a single generic connection to take care of one part of man...
vrpn_int32 * d_connectionCounter
const vrpn_uint32 vrpn_CONNECTION_FIXED_LATENCY
#define SOCKET
Definition: vrpn_Shared.h:46
int d_serverLogCount
Server logging w. multiconnection - TCH July 00 Use one "hidden" endpoint for outgoing logs (...
virtual void drop_connection(void)=0
Should only be called by vrpn_Connection::drop_connection(), since there&#39;s more housecleaning to do a...
const long vrpn_LOG_INCOMING
virtual vrpn_bool connected(void) const
Returns vrpn_true if the connection has been established, vrpn_false if not (For a networkless connec...
const int vrpn_CONNECTION_MAX_TYPES
vrpn_Log * d_inLog
SOCKET listen_udp_sock
UDP Connect requests come here.
vrpn_TranslationTable * d_senders
vrpn_bool d_updateEndpoint
VRPN_API int write_vrpn_cookie(char *buffer, size_t length, long remote_log_mode)
Writes the magic cookie into buffer with given length.
VRPN_API char * vrpn_copy_rsh_arguments(const char *hostspecifier)
const int vrpn_CONNECTION_MAX_SENDERS
Types now have their storage dynamically allocated, so we can afford to have large tables...
vrpn_HANDLERPARAM data
vrpn_int32 d_numConnectedEndpoints
We need to track the number of connected endpoints separately to properly send out got-first-connecti...
const vrpn_uint32 vrpn_CONNECTION_HIGH_THROUGHPUT
class VRPN_API vrpn_TypeDispatcher
VRPN_API char * vrpn_copy_rsh_program(const char *hostspecifier)
virtual void poll_for_cookie(const timeval *timeout=NULL)=0
virtual vrpn_bool doing_okay(void) const
Returns vrpn_true if the connection is okay, vrpn_false if not.
VRPN_API int check_vrpn_cookie(const char *buffer)
Checks the buffer to see if it is a valid VRPN header cookie. Returns -1 on total mismatch...
vrpn_int32 d_udpNumOut
const int vrpn_CONNECTION_TCP_BUFLEN
vrpnMsgCallbackEntry * next
Next handler.
#define vrpn_DEFAULT_LISTEN_PORT_NO
timeval d_last_connect_attempt
When the last UDP lob occurred.
VRPN_API char * vrpn_copy_machine_name(const char *hostspecifier)
const int vrpn_CONNECTION_UDP_BUFLEN
SOCKET d_udpInboundSocket
Inbound unreliable messages come here. Need one for each due to different clock synchronization for e...
vrpn_bool d_tcp_only
For connections made through firewalls or NAT with the tcp: URL, we do not want to allow the endpoint...
const int vrpn_MAX_ENDPOINTS
Number of endpoints that a server connection can have. Arbitrary limit.
vrpn_TypeDispatcher * d_dispatcher
Derived classes need access to d_dispatcher in their allocateEndpoint() routine. Several compilers wo...
virtual vrpn_bool doing_okay(void) const =0
vrpn_TypeDispatcher * d_dispatcher
VRPN_API char * vrpn_copy_service_name(const char *fullname)
SOCKET d_tcpListenSocket
This section deals with when a client connection is trying to establish (or re-establish) a connectio...
vrpn_LOGLIST * next
Placed here so vrpn_FileConnection can use it too.
vrpn_TranslationTable * d_types
VRPN_API vrpn_Connection * vrpn_create_server_connection(const char *cname, const char *local_in_logfile_name=NULL, const char *local_out_logfile_name=NULL)
Create a server connection of arbitrary type (VRPN UDP/TCP, TCP, File, Loopback, MPI).
vrpn_int32 d_tcpBuflen
SOCKET d_udpLobSocket
Socket to use to lob UDP requests asking for the server to call us back.
const int vrpn_ANY_SENDER
vrpn_ANY_SENDER can be used to register callbacks on a given message type from any sender...