00001 /* Client Class */ 00002 #include <ros/ros.h> 00003 #include <sys/socket.h> 00004 #include <sys/types.h> 00005 #include <netinet/in.h> 00006 #include <netdb.h> 00007 #include <stdio.h> 00008 #include <string.h> 00009 #include <stdlib.h> 00010 #include <unistd.h> 00011 #include <errno.h> 00012 #include <pthread.h> 00013 00014 class Client 00015 { 00016 public: 00017 Client(); 00018 ~Client(); 00019 void initClient(); 00020 void re_initClient(); 00021 void receiveFromServer(); 00022 void requestMeasurments(); 00023 void start_stopBroadcasting(int frq); 00024 void on_offChannel(char,char); 00025 void *print_message_function( void *ptr ); 00026 void explore(); 00027 friend void* proxy_function(void*); 00028 void thread_function(); 00029 //void reinitiate(int sock); 00030 private: 00031 void create_thread(); 00032 //void thread_function(); 00033 //ros::NodeHandle n_; 00034 //char *message1; 00035 //char *message2; 00036 char delim; 00037 char command; 00038 ushort length; 00039 char n; 00040 int max_curr; 00041 int max_vol; 00042 unsigned char nbuffer[255]; 00043 unsigned char * p; 00044 int sock, bytes_recieved; 00045 unsigned char send_data[255],recv_data[255]; 00046 bool initiate; 00047 struct hostent *host; 00048 struct sockaddr_in server_addr; 00049 pthread_t thread1, thread2; 00050 };