vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
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
10
11#if !(defined(_WIN32) && defined(VRPN_USE_WINSOCK_SOCKETS))
12#include <sys/select.h> // for fd_set
13#endif
14
15struct timeval;
16
17// Don't complain about using sprintf() when using Visual Studio.
18#ifdef _MSC_VER
19#pragma warning(disable : 4995 4996)
20#endif
21
26 LISTEN = (1),
27 CONNECTED = (0),
30 BROKEN = (-3),
31 LOGGING = (-4)
32};
33
34class VRPN_API
35 vrpn_File_Connection; // Forward declaration for get_File_Connection()
36
42 vrpn_int32 type;
43 vrpn_int32 sender;
44 struct timeval msg_time;
45 vrpn_int32 payload_len;
46 const char *buffer;
47};
48
50typedef int(VRPN_CALLBACK *vrpn_MESSAGEHANDLER)(void *userdata,
52
56
60const unsigned vrpn_ALIGN = 8;
61
70
73
74const int vrpn_ANY_SENDER = -1;
75
78
79const int vrpn_ANY_TYPE = -1;
80
92
96
99
100const int vrpn_MAX_ENDPOINTS = 256;
101
105const vrpn_int32 vrpn_CONNECTION_TYPE_DESCRIPTION = (-2);
106const vrpn_int32 vrpn_CONNECTION_UDP_DESCRIPTION = (-3);
107const vrpn_int32 vrpn_CONNECTION_LOG_DESCRIPTION = (-4);
110
117
118const vrpn_uint32 vrpn_CONNECTION_RELIABLE = (1 << 0);
119const vrpn_uint32 vrpn_CONNECTION_FIXED_LATENCY = (1 << 1);
120const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY = (1 << 2);
121const vrpn_uint32 vrpn_CONNECTION_FIXED_THROUGHPUT = (1 << 3);
122const vrpn_uint32 vrpn_CONNECTION_HIGH_THROUGHPUT = (1 << 4);
123
125
128const long vrpn_LOG_NONE = (0);
129const long vrpn_LOG_INCOMING = (1 << 0);
130const long vrpn_LOG_OUTGOING = (1 << 1);
132
133// If defined, will filter out messages: if the remote side hasn't
134// registered a type, messages of that type won't be sent over the
135// link. WARNING: auto-type-registration breaks this.
136//#define vrpn_FILTER_MESSAGES
137
141extern VRPN_API const char *vrpn_got_first_connection;
142extern VRPN_API const char *vrpn_got_connection;
143extern VRPN_API const char *vrpn_dropped_connection;
144extern VRPN_API const char *vrpn_dropped_last_connection;
146
152
153extern VRPN_API const char *vrpn_CONTROL;
154
156typedef char cName[100];
157
163};
164
167
169typedef vrpn_Endpoint_IP *(*vrpn_EndpointAllocator)(
170 vrpn_Connection *connection, vrpn_int32 *numActiveConnections);
171
172namespace vrpn {
173
178 public:
180 : epa_(NULL)
181 , conn_(NULL)
182 , numActiveEndpoints_(NULL)
183 {
184 }
186 vrpn_Connection *conn,
187 vrpn_int32 *numActiveEndpoints = NULL)
188 : epa_(epa)
189 , conn_(conn)
190 , numActiveEndpoints_(numActiveEndpoints)
191 {
192 }
193
195
198 {
199 if (!epa_) {
200 return NULL;
201 }
202 return (*epa_)(conn_, numActiveEndpoints_);
203 }
204
206 return_type operator()(vrpn_int32 *alternateNumActiveEndpoints) const
207 {
208 if (!epa_) {
209 return NULL;
210 }
211 return (*epa_)(conn_, alternateNumActiveEndpoints);
212 }
213
214 private:
216 vrpn_Connection *conn_;
217 vrpn_int32 *numActiveEndpoints_;
218 };
219} // namespace vrpn
225
229 void *userdata;
230 vrpn_int32 sender;
232};
233
236 void *userdata;
238};
240
245
252
254
255public:
257 vrpn_int32 *connectedEndpointCounter);
258 virtual ~vrpn_Endpoint(void);
259
262
264 int local_type_id(vrpn_int32 remote_type) const;
265
267 int local_sender_id(vrpn_int32 remote_sender) const;
268
269 virtual vrpn_bool doing_okay(void) const = 0;
271
274
275 void init(void);
276
277 virtual int mainloop(timeval *timeout) = 0;
278
282 void clear_other_senders_and_types(void);
283
287 int newLocalSender(const char *name, vrpn_int32 which);
288 int newLocalType(const char *name, vrpn_int32 which);
289
293 int newRemoteType(cName type_name, vrpn_int32 remote_id,
294 vrpn_int32 local_id);
295 int newRemoteSender(cName sender_name, vrpn_int32 remote_id,
296 vrpn_int32 local_id);
298
301 virtual int pack_message(vrpn_uint32 len, struct timeval time,
302 vrpn_int32 type, vrpn_int32 sender,
303 const char *buffer,
304 vrpn_uint32 class_of_service) = 0;
305
309 virtual int send_pending_reports(void) = 0;
310
311 int pack_log_description(void);
313
314 virtual int setup_new_connection(void) = 0;
317
318 virtual void poll_for_cookie(const timeval *timeout = NULL) = 0;
319 virtual int finish_new_connection_setup(void) = 0;
320
321 virtual void drop_connection(void) = 0;
325
326 virtual void clearBuffers(void) = 0;
329
330 int pack_sender_description(vrpn_int32 which);
332
333 int pack_type_description(vrpn_int32 which);
335
338
342
346
350 char rhostname[150];
351
356
359
360 void setLogNames(const char *inName, const char *outName);
361 int openLogs(void);
363
368 static int VRPN_CALLBACK
369 handle_sender_message(void *userdata, vrpn_HANDLERPARAM p);
370 static int VRPN_CALLBACK
371 handle_type_message(void *userdata, vrpn_HANDLERPARAM p);
373
377 void setConnection(vrpn_Connection *conn) { d_parent = conn; }
378 vrpn_Connection *getConnection() { return d_parent; }
380
381protected:
382 virtual int dispatch(vrpn_int32 type, vrpn_int32 sender, timeval time,
383 vrpn_uint32 payload_len, char *bufptr);
384
385 int tryToMarshall(char *outbuf, vrpn_int32 &buflen, vrpn_int32 &numOut,
386 vrpn_uint32 len, timeval time, vrpn_int32 type,
387 vrpn_int32 sender, const char *buffer,
388 vrpn_uint32 classOfService);
392
393 int marshall_message(char *outbuf, vrpn_uint32 outbuf_size,
394 vrpn_uint32 initial_out, vrpn_uint32 len,
395 struct timeval time, vrpn_int32 type,
396 vrpn_int32 sender, const char *buffer,
397 vrpn_uint32 sequenceNumber);
398
399 // The senders and types we know about that have been described by
400 // the other end of the connection. Also, record the local mapping
401 // for ones that have been described with the same name locally.
402 // The arrays are indexed by the ID from the other side, and store
403 // the name and local ID that corresponds to each.
404
407
410
412};
413
421
423
424public:
426 vrpn_int32 *connectedEndpointCounter);
427 virtual ~vrpn_Endpoint_IP(void);
428
431 virtual vrpn_bool doing_okay(void) const;
432
434 vrpn_bool outbound_udp_open(void) const;
435
436 vrpn_int32 tcp_outbuf_size(void) const;
437 vrpn_int32 udp_outbuf_size(void) const;
439
442
443 void init(void);
444
445 int mainloop(timeval *timeout);
446
451 int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type,
452 vrpn_int32 sender, const char *buffer,
453 vrpn_uint32 class_of_service);
454
459 virtual int send_pending_reports(void);
460
461 int pack_udp_description(int portno);
462
463 int handle_tcp_messages(const timeval *timeout);
464 int handle_udp_messages(const timeval *timeout);
465
466 int connect_tcp_to(const char *msg);
467 int connect_tcp_to(const char *addr, int port);
470 int connect_udp_to(const char *addr, int port);
474
475 int setup_new_connection(void);
478
479 void poll_for_cookie(const timeval *timeout = NULL);
480 int finish_new_connection_setup(void);
481
482 void drop_connection(void);
486
487 void clearBuffers(void);
490
491 void setNICaddress(const char *);
492
496
498
502
508
512
516
517 vrpn_bool d_tcp_only;
522
523protected:
524 int getOneTCPMessage(int fd, char *buf, size_t buflen);
525 int getOneUDPMessage(char *buf, size_t buflen);
526
534
537 vrpn_int32 d_tcpBuflen;
538 vrpn_int32 d_udpBuflen;
539 vrpn_int32 d_tcpNumOut;
540 vrpn_int32 d_udpNumOut;
541
544
545 vrpn_float64
546 d_tcpAlignedInbuf[vrpn_CONNECTION_TCP_BUFLEN / sizeof(vrpn_float64) +
547 1];
548 vrpn_float64
549 d_udpAlignedInbuf[vrpn_CONNECTION_UDP_BUFLEN / sizeof(vrpn_float64) +
550 1];
553
555};
556
562
563protected:
568 vrpn_Connection(const char *local_in_logfile_name,
569 const char *local_out_logfile_name,
570 vrpn_EndpointAllocator epa = allocateEndpoint);
571
575 vrpn_Connection(const char *local_in_logfile_name,
576 const char *local_out_logfile_name,
577 const char *remote_in_logfile_name,
578 const char *remote_out_logfile_name,
579 vrpn_EndpointAllocator epa = allocateEndpoint);
580
581public:
582 virtual ~vrpn_Connection(void);
583
585 virtual vrpn_bool doing_okay(void) const;
586
590 virtual vrpn_bool connected(void) const;
591
598 void get_log_names(char **local_in_logname, char **local_out_logname,
599 char **remote_in_logname, char **remote_out_logname);
600
608 virtual int mainloop(const struct timeval *timeout = NULL) = 0;
609
612 virtual vrpn_int32 register_sender(const char *name);
613 virtual vrpn_int32 register_message_type(const char *name);
614
620 virtual int register_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler,
621 void *userdata,
622 vrpn_int32 sender = vrpn_ANY_SENDER);
623 virtual int unregister_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler,
624 void *userdata,
625 vrpn_int32 sender = vrpn_ANY_SENDER);
626
629 virtual int pack_message(vrpn_uint32 len, struct timeval time,
630 vrpn_int32 type, vrpn_int32 sender,
631 const char *buffer, vrpn_uint32 class_of_service);
632
636 virtual int send_pending_reports(void) = 0;
637
640 virtual int time_since_connection_open(struct timeval *elapsed_time);
641
644 virtual timeval get_time();
645
649 virtual const char *sender_name(vrpn_int32 sender);
650 virtual const char *message_type_name(vrpn_int32 type);
651
659 virtual int register_log_filter(vrpn_LOGFILTER filter, void *userdata);
660
662 virtual int save_log_so_far();
663
666 virtual vrpn_File_Connection *get_File_Connection(void);
667
688 void Jane_stop_this_crazy_thing(vrpn_uint32 stop_looking_after)
689 {
690 d_stop_processing_messages_after = stop_looking_after;
691 };
692 vrpn_uint32 get_Jane_value(void)
693 {
694 return d_stop_processing_messages_after;
695 };
696
697protected:
702
704
710 static vrpn_Endpoint_IP *allocateEndpoint(vrpn_Connection *,
711 vrpn_int32 *connectedEC);
712
713#ifdef _MSC_VER
714#pragma warning(push)
715// Disable "need dll interface" warning on these members
716#pragma warning(disable : 4251)
717#endif
721
725
726#ifdef _MSC_VER
727#pragma warning(pop)
728#endif
734
737 static int VRPN_CALLBACK
738 handle_log_message(void *userdata, vrpn_HANDLERPARAM p);
739 static int VRPN_CALLBACK
740 handle_disconnect_message(void *userdata, vrpn_HANDLERPARAM p);
742
743private:
744 void init(vrpn_EndpointAllocator
745 epa);
746protected:
747 int delete_endpoint(vrpn_Endpoint *endpoint);
748 int compact_endpoints(void);
749
750 virtual int pack_sender_description(vrpn_int32 which);
752
753 virtual int pack_type_description(vrpn_int32 which);
755
756 virtual int do_callbacks_for(vrpn_int32 type, vrpn_int32 sender,
757 struct timeval time, vrpn_uint32 len,
758 const char *buffer);
759
761 int message_type_is_registered(const char *) const;
762
764 timeval start_time;
765
766 //
768public:
769 void addReference();
770 void removeReference();
771
772private:
773 int d_references;
774
775 //
786public:
787 void setAutoDeleteStatus(bool setvalue) { d_autoDeleteStatus = setvalue; }
788
789private:
790 bool d_autoDeleteStatus;
791
792public:
797
799
800protected:
801 int doSystemCallbacksFor(vrpn_HANDLERPARAM, void *);
802
811
812 // vrpn_Endpoint * d_serverLogEndpoint;
814 vrpn_int32 d_serverLogMode;
816
818
819 virtual void updateEndpoints(void);
825};
826
828
829protected:
841 vrpn_Connection_IP(const char *server_name,
843 const char *local_in_logfile_name = NULL,
844 const char *local_out_logfile_name = NULL,
845 const char *remote_in_logfile_name = NULL,
846 const char *remote_out_logfile_name = NULL,
847 const char *NIC_IPaddress = NULL,
848 vrpn_EndpointAllocator epa = allocateEndpoint);
849
850public:
855 unsigned short listen_port_no = vrpn_DEFAULT_LISTEN_PORT_NO,
856 const char *local_in_logfile_name = NULL,
857 const char *local_out_logfile_name = NULL,
858 const char *NIC_IPaddress = NULL,
860 vrpn_int32 *) = allocateEndpoint);
861
862 virtual ~vrpn_Connection_IP(void);
863
866 virtual int connect_to_client(const char *machine, int port);
867
875 virtual int mainloop(const struct timeval *timeout = NULL);
876
877protected:
882
884 const char *cname, const char *local_in_logfile_name,
885 const char *local_out_logfile_name, const char *remote_in_logfile_name,
886 const char *remote_out_logfile_name, const char *NIC_IPaddress,
887 bool force_connection);
889 vrpn_create_server_connection(const char *cname,
890 const char *local_in_logfile_name,
891 const char *local_out_logfile_name);
892
898
900 static int VRPN_CALLBACK
901 handle_UDP_message(void *userdata, vrpn_HANDLERPARAM p);
902
904 void init(void);
905
910 virtual int send_pending_reports(void);
911
915 virtual void
916 server_check_for_incoming_connections(const struct timeval *timeout = NULL);
917
921 virtual void handle_connection(vrpn_Endpoint *endpoint);
922
926 virtual void drop_connection(vrpn_Endpoint *endpoint);
927
931 void drop_connection_and_compact(vrpn_Endpoint *endpoint);
932
933 char *d_NIC_IP;
934};
935
941
943
944protected:
950
951public:
952 virtual ~vrpn_Connection_Loopback(void);
953
960 virtual int mainloop(const struct timeval *timeout = NULL);
961
963 virtual vrpn_bool doing_okay(void) const { return vrpn_true; }
964
968 virtual vrpn_bool connected(void) const { return vrpn_true; }
969
970protected:
972 vrpn_create_server_connection(const char *cname,
973 const char *local_in_logfile_name,
974 const char *local_out_logfile_name);
975
980 virtual int send_pending_reports(void) { return 0; }
981};
982
993 const char *cname, const char *local_in_logfile_name = NULL,
994 const char *local_out_logfile_name = NULL,
995 const char *remote_in_logfile_name = NULL,
996 const char *remote_out_logfile_name = NULL,
997 const char *NIC_IPaddress = NULL, bool force_reopen = false);
998
1016vrpn_create_server_connection(const char *cname,
1017 const char *local_in_logfile_name = NULL,
1018 const char *local_out_logfile_name = NULL);
1019
1026 const char *local_in_logfile_name = NULL,
1027 const char *local_out_logfile_name = NULL,
1028 const char *NIC_NAME = NULL)
1029{
1030 char name[256];
1031 if (NIC_NAME == NULL) {
1032 sprintf(name, ":%d", port);
1033 }
1034 else {
1035 sprintf(name, "%s:%d", NIC_NAME, port);
1036 }
1037 return vrpn_create_server_connection(name, local_in_logfile_name,
1038 local_out_logfile_name);
1039}
1040
1045VRPN_API char *vrpn_copy_service_name(const char *fullname);
1046VRPN_API char *vrpn_copy_service_location(const char *fullname);
1048
1056VRPN_API char *vrpn_copy_file_name(const char *filespecifier);
1057
1073VRPN_API char *vrpn_copy_machine_name(const char *hostspecifier);
1074VRPN_API int vrpn_get_port_number(const char *hostspecifier);
1075VRPN_API char *vrpn_copy_rsh_program(const char *hostspecifier);
1076VRPN_API char *vrpn_copy_rsh_arguments(const char *hostspecifier);
1078
1080char *vrpn_set_service_name(const char *specifier, const char *newServiceName);
1081
1087VRPN_API int check_vrpn_cookie(const char *buffer);
1088VRPN_API int check_vrpn_file_cookie(const char *buffer);
1090
1093VRPN_API size_t vrpn_cookie_size(void);
1094
1095VRPN_API int write_vrpn_cookie(char *buffer, size_t length,
1096 long remote_log_mode);
1097
1101#ifndef VRPN_USE_WINSOCK_SOCKETS
1102int VRPN_API
1103vrpn_noint_block_write(int outfile, const char buffer[], size_t length);
1104int VRPN_API vrpn_noint_block_read(int infile, char buffer[], size_t length);
1105int VRPN_API vrpn_noint_select(int width, fd_set *readfds, fd_set *writefds,
1106 fd_set *exceptfds, struct timeval *timeout);
1107#else /* winsock sockets */
1108int VRPN_API
1109vrpn_noint_block_write(SOCKET outsock, char *buffer, size_t length);
1110int VRPN_API vrpn_noint_block_read(SOCKET insock, char *buffer, size_t length);
1111#endif /* VRPN_USE_WINSOCK_SOCKETS */
1113
1126// This section holds data structures and functions to open
1127// connections by name.
1128// The intention of this section is that it can open connections for
1129// objects that are in different libraries (trackers, buttons and sound),
1130// even if they all refer to the same connection.
1131// Even though each individual vrpn_Connection class is not yet thread
1132// safe, so should only have its methods called from a single thread,
1133// the vrpn_ConnectionManager should be thread safe to allow connections
1134// to be created and destroyed by different threads.
1135
1137
1138public:
1140
1146 static vrpn_ConnectionManager &instance(void);
1147
1151 void addConnection(vrpn_Connection *, const char *name);
1152 void deleteConnection(vrpn_Connection *);
1154
1157 vrpn_Connection *getByName(const char *name);
1158
1159private:
1161 vrpn_Semaphore d_semaphore;
1162
1163 struct knownConnection {
1164 char name[1000];
1165 vrpn_Connection *connection;
1166 knownConnection *next;
1167 };
1168
1170 knownConnection *d_kcList;
1171
1173 knownConnection *d_anonList;
1174
1176
1177 // @brief copy constructor undefined to prevent instantiations
1179
1180 void deleteConnection(vrpn_Connection *, knownConnection **);
1181};
1182
1183#endif // VRPN_CONNECTION_H
Combines the function pointer for an Endpoint Allocator with its two arguments into a single callable...
return_type operator()() const
Default, fully pre-bound.
vrpn_Endpoint_IP * return_type
return_type operator()(vrpn_int32 *alternateNumActiveEndpoints) const
Overload, with alternate num active connnection pointer.
BoundEndpointAllocator(vrpn_EndpointAllocator epa, vrpn_Connection *conn, vrpn_int32 *numActiveEndpoints=NULL)
Container for endpoints, held by pointer.
Singleton class that keeps track of all known VRPN connections and makes sure they're deleted on shut...
SOCKET listen_udp_sock
UDP Connect requests come here.
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...
vrpn_Connection_IP(const char *server_name, int port=vrpn_DEFAULT_LISTEN_PORT_NO, 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, vrpn_EndpointAllocator epa=allocateEndpoint)
Make a client connection. To access this from user code, call vrpn_get_connection_by_name()....
SOCKET listen_tcp_sock
TCP Connection requests come here.
Constructor for a Loopback connection that will basically just pass messages between objects that are...
virtual vrpn_bool doing_okay(void) const
Returns vrpn_true if the connection is okay, vrpn_false if not.
virtual int send_pending_reports(void)
send pending report, clear the buffer.
virtual vrpn_bool connected(void) const
Returns vrpn_true if the connection has been established, vrpn_false if not (For a networkless connec...
Generic connection class not specific to the transport mechanism.
int d_serverLogCount
Server logging w. multiconnection - TCH July 00 Use one "hidden" endpoint for outgoing logs (?...
virtual int send_pending_reports(void)=0
send pending report, clear the buffer. This function was protected, now is public,...
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...
vrpn_int32 d_numConnectedEndpoints
We need to track the number of connected endpoints separately to properly send out got-first-connecti...
vrpn_bool d_updateEndpoint
vrpn_TypeDispatcher * d_dispatcher
Derived classes need access to d_dispatcher in their allocateEndpoint() routine. Several compilers wo...
vrpn_int32 d_serverLogMode
vrpn::EndpointContainer d_endpoints
Sockets used to talk to remote Connection(s) and other information needed on a per-connection basis.
vrpn_uint32 get_Jane_value(void)
void setAutoDeleteStatus(bool setvalue)
Specify whether this connection should be deleted automatically when it is no longer need (reference ...
int connectionStatus
Status of the connection.
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...
timeval start_time
Timekeeping - TCH 30 June 98.
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...
vrpn::BoundEndpointAllocator d_boundEndpointAllocator
Function object wrapping an endpoint allocator and binding its arguments.
Encapsulation of the data and methods for a single IP-based connection to take care of one part of ma...
SOCKET d_udpInboundSocket
Inbound unreliable messages come here. Need one for each due to different clock synchronization for e...
vrpn_int32 d_udpBuflen
SOCKET d_tcpListenSocket
This section deals with when a client connection is trying to establish (or re-establish) a connectio...
vrpn_int32 d_udpSequenceNumber
timeval d_last_connect_attempt
When the last UDP lob occurred.
char * d_remote_machine_name
Machine to call.
vrpn_int32 d_udpNumOut
vrpn_bool d_tcp_only
For connections made through firewalls or NAT with the tcp: URL, we do not want to allow the endpoint...
int d_tcpListenPort
Socket and port that the client listens on when lobbing datagrams at the server and waiting for it to...
int d_remote_port_number
Port to connect to on remote machine.
vrpn_int32 d_tcpNumOut
SOCKET d_udpLobSocket
Socket to use to lob UDP requests asking for the server to call us back.
vrpn_int32 d_tcpBuflen
vrpn_int32 d_tcpSequenceNumber
Encapsulation of the data and methods for a single generic connection to take care of one part of man...
void setConnection(vrpn_Connection *conn)
vrpn_Log * d_outLog
virtual vrpn_bool doing_okay(void) const =0
long d_remoteLogMode
Mode to put the remote logging in.
vrpn_TypeDispatcher * d_dispatcher
virtual int send_pending_reports(void)=0
send pending report, clear the buffer. This function was protected, now is public,...
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 ...
virtual int mainloop(timeval *timeout)=0
vrpn_Connection * getConnection()
virtual void drop_connection(void)=0
Should only be called by vrpn_Connection::drop_connection(), since there's more housecleaning to do a...
vrpn_int32 * d_connectionCounter
char * d_remoteInLogName
Name of the remote log file.
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...
virtual int finish_new_connection_setup(void)=0
virtual void poll_for_cookie(const timeval *timeout=NULL)=0
vrpn_TranslationTable * d_senders
vrpn_Connection * d_parent
vrpn_Log * d_inLog
virtual void clearBuffers(void)=0
Empties out the TCP and UDP send buffers. Needed by vrpn_FileConnection to get at {udp,...
vrpn_TranslationTable * d_types
char * d_remoteOutLogName
Name of the remote log file.
Logs a VRPN stream.
Definition: vrpn_Log.h:10
vrpn_LOGFILTER filter
routine to call
void * userdata
passed along
vrpnLogFilterEntry * next
Description of a callback entry for a user type.
vrpnMsgCallbackEntry * next
Next handler.
void * userdata
Passed along.
vrpn_int32 sender
Only if from sender.
vrpn_MESSAGEHANDLER handler
Routine to call.
This structure is what is passed to a vrpn_Connection message callback.
const char * buffer
struct timeval msg_time
vrpn_int32 payload_len
Placed here so vrpn_FileConnection can use it too.
vrpn_LOGLIST * next
vrpn_HANDLERPARAM data
vrpn_LOGLIST * prev
#define VRPN_API
#define vrpn_DEFAULT_LISTEN_PORT_NO
#define VRPN_CALLBACK
vrpn_Connection * vrpn_create_server_connection(const char *cname, const char *local_in_logfile_name, const char *local_out_logfile_name)
Create a server connection of arbitrary type (VRPN UDP/TCP, TCP, File, Loopback, MPI).
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, const char *NIC_IPaddress, bool force_connection)
Create a client connection of arbitrary type (VRPN UDP/TCP, TCP, File, Loopback, MPI).
const long vrpn_LOG_NONE
const vrpn_int32 vrpn_CONNECTION_UDP_DESCRIPTION
const int vrpn_CONNECTION_UDP_BUFLEN
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
VRPN_API char * vrpn_copy_rsh_arguments(const char *hostspecifier)
const vrpn_int32 vrpn_CONNECTION_LOG_DESCRIPTION
const int vrpn_CONNECTION_MAX_SENDERS
Types now have their storage dynamically allocated, so we can afford to have large tables....
const vrpn_int32 vrpn_CONNECTION_TYPE_DESCRIPTION
const int vrpn_ANY_SENDER
vrpn_ANY_SENDER can be used to register callbacks on a given message type from any sender.
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_API int check_vrpn_file_cookie(const char *buffer)
const unsigned vrpn_ALIGN
VRPN buffers are aligned on 8 byte boundaries so that we can pack and unpack doubles into them on arc...
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_API int write_vrpn_cookie(char *buffer, size_t length, long remote_log_mode)
Writes the magic cookie into buffer with given length.
vrpn_Endpoint_IP *(* vrpn_EndpointAllocator)(vrpn_Connection *connection, vrpn_int32 *numActiveConnections)
Function pointer to an endpoint allocator.
const vrpn_uint32 vrpn_CONNECTION_FIXED_THROUGHPUT
const int vrpn_MAX_ENDPOINTS
Number of endpoints that a server connection can have. Arbitrary limit.
VRPN_API int vrpn_get_port_number(const char *hostspecifier)
VRPN_API char * vrpn_copy_file_name(const char *filespecifier)
Utility routines to parse file specifiers FROM service locations.
vrpn_MESSAGEHANDLER vrpn_LOGFILTER
Type of handler for filters on logfiles is the same as connection handler.
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_API char * vrpn_copy_service_name(const char *fullname)
int(VRPN_CALLBACK * vrpn_MESSAGEHANDLER)(void *userdata, vrpn_HANDLERPARAM p)
Type of a message handler for vrpn_Connection messages.
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_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).
char cName[100]
Length of names within VRPN.
const vrpn_uint32 vrpn_CONNECTION_FIXED_LATENCY
VRPN_API char * vrpn_copy_service_location(const char *fullname)
class VRPN_API vrpn_TypeDispatcher
VRPN_API const char * vrpn_dropped_connection
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_API const char * vrpn_got_connection
class VRPN_API vrpn_TranslationTable
const int vrpn_CONNECTION_MAX_TYPES
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
VRPN_API char * vrpn_copy_rsh_program(const char *hostspecifier)
char * vrpn_set_service_name(const char *specifier, const char *newServiceName)
Utility routine to rename the service name of a given host specifier.
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).
const vrpn_int32 vrpn_CONNECTION_DISCONNECT_MESSAGE
const int vrpn_CONNECTION_TCP_BUFLEN
VRPN_API char * vrpn_copy_machine_name(const char *hostspecifier)
int VRPN_API vrpn_noint_block_write(int outfile, const char buffer[], size_t length)
const vrpn_int32 vrpn_CONNECTION_SENDER_DESCRIPTION
VRPN_API const char * vrpn_dropped_last_connection
const vrpn_uint32 vrpn_CONNECTION_HIGH_THROUGHPUT
vrpn_ConnectionStatus
This is the list of states that a connection can be in (possible values for status)....
@ LISTEN
@ CONNECTED
@ TRYING_TO_CONNECT
@ LOGGING
@ BROKEN
@ COOKIE_PENDING
const long vrpn_LOG_OUTGOING
const long vrpn_LOG_INCOMING
VRPN_API size_t vrpn_cookie_size(void)
Returns the size of the magic cookie buffer, plus any alignment overhead.
int VRPN_API vrpn_noint_block_read(int infile, char buffer[], size_t length)
#define SOCKET
Definition: vrpn_Shared.h:52