00001 /**********************************************************************************************/ 00002 /*************************** UDP GROUP CHANNEL CLASS *************************/ 00003 /**************************** Jean FANCHON. LAAS-CNRS*************************/ 00004 /**********************************************************************************************/ 00005 #include <stdio.h> 00006 #include <stdlib.h> 00007 #include <sys/types.h> 00008 #include <sys/socket.h> 00009 #include <netinet/in.h> 00010 #include <arpa/inet.h> 00011 #include <netdb.h> 00012 #include <iostream.h> 00013 #include <string.h> 00014 #include <fstream.h> 00015 #include <pthread.h> 00016 #include <unistd.h> 00017 #include <errno.h> 00018 00019 // #include "channel.h" 00020 // #include "channeluser.h" 00021 00022 #define MAX_MEMBER 15 00023 00024 #define BASEPORT 18131 00025 00026 /*******************************************************************************/ 00027 /******************************************************************************/ 00028 00029 class total_order_channel; 00030 00031 class group_admin; 00032 00033 class no_prop_channel { // :public channel { 00034 00035 /********************************************************************/ 00036 /*interface*/ 00037 00038 public: 00039 00040 no_prop_channel(total_order_channel *, const char * , group_admin *); 00041 00042 no_prop_channel(total_order_channel * pt, int id , char * file, group_admin *); 00043 00044 ~no_prop_channel(); 00045 00046 /********************************************************************/ 00047 /* communication */ 00048 00049 int read_socket() ; // code for the reading thread on UDP port 00050 00051 int broadcast(char *, int); 00052 00053 int multicast(int , int *, char* , int ) ; 00054 00055 int unicast(int , char *, int); 00056 00057 /********************************************************************/ 00058 /* membership */ 00059 00060 int init_membership(char *, char * , int); 00061 00062 int get_mynode(); 00063 00064 int get_myport(); 00065 00066 int my_ident; /* local member ident */ 00067 00068 private : 00069 00070 total_order_channel *my_user; // user's address 00071 00072 /********************************************************************/ 00073 /* networking */ 00074 00075 int sServ; //local socket file number 00076 00077 pthread_t read_thread; // struct for the reading thread on UDP port 00078 00079 00080 /********************************************************************/ 00081 /* Group data */ 00082 00083 group_admin *my_group; 00084 00085 char hostname[15]; 00086 00087 int my_nodeid; 00088 00089 int my_port; 00090 00091 00092 }; 00093 00094