Changeset 5829 in orxonox.OLD for branches/network/src/subprojects
- Timestamp:
- Nov 30, 2005, 9:43:05 AM (19 years ago)
- Location:
- branches/network/src/subprojects/network
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/subprojects/network/Makefile.am
r5822 r5829 15 15 network_SOURCES= network_unit_test.cc \ 16 16 simple_sync.cc \ 17 read_sync.cc \ 18 write_sync.cc \ 17 19 \ 18 20 \ … … 26 28 27 29 noinst_HEADERS = network_unit_test.h \ 28 simple_sync.h 30 simple_sync.h \ 31 read_sync.h \ 32 write_sync.h 29 33 -
branches/network/src/subprojects/network/Makefile.in
r5822 r5829 54 54 PROGRAMS = $(bin_PROGRAMS) 55 55 am_network_OBJECTS = network-network_unit_test.$(OBJEXT) \ 56 network-simple_sync.$(OBJEXT) network-base_object.$(OBJEXT) \ 56 network-simple_sync.$(OBJEXT) network-read_sync.$(OBJEXT) \ 57 network-write_sync.$(OBJEXT) network-base_object.$(OBJEXT) \ 57 58 network-class_list.$(OBJEXT) network-load_param.$(OBJEXT) \ 58 59 network-substring.$(OBJEXT) network-helper_functions.$(OBJEXT) … … 193 194 network_SOURCES = network_unit_test.cc \ 194 195 simple_sync.cc \ 196 read_sync.cc \ 197 write_sync.cc \ 195 198 \ 196 199 \ … … 202 205 203 206 noinst_HEADERS = network_unit_test.h \ 204 simple_sync.h 207 simple_sync.h \ 208 read_sync.h \ 209 write_sync.h 205 210 206 211 all: all-am … … 275 280 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-load_param.Po@am__quote@ 276 281 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-network_unit_test.Po@am__quote@ 282 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-read_sync.Po@am__quote@ 277 283 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-simple_sync.Po@am__quote@ 278 284 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-substring.Po@am__quote@ 285 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-write_sync.Po@am__quote@ 279 286 280 287 .cc.o: … … 319 326 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 320 327 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-simple_sync.obj `if test -f 'simple_sync.cc'; then $(CYGPATH_W) 'simple_sync.cc'; else $(CYGPATH_W) '$(srcdir)/simple_sync.cc'; fi` 328 329 network-read_sync.o: read_sync.cc 330 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-read_sync.o -MD -MP -MF "$(DEPDIR)/network-read_sync.Tpo" -c -o network-read_sync.o `test -f 'read_sync.cc' || echo '$(srcdir)/'`read_sync.cc; \ 331 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/network-read_sync.Tpo" "$(DEPDIR)/network-read_sync.Po"; else rm -f "$(DEPDIR)/network-read_sync.Tpo"; exit 1; fi 332 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='read_sync.cc' object='network-read_sync.o' libtool=no @AMDEPBACKSLASH@ 333 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 334 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-read_sync.o `test -f 'read_sync.cc' || echo '$(srcdir)/'`read_sync.cc 335 336 network-read_sync.obj: read_sync.cc 337 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-read_sync.obj -MD -MP -MF "$(DEPDIR)/network-read_sync.Tpo" -c -o network-read_sync.obj `if test -f 'read_sync.cc'; then $(CYGPATH_W) 'read_sync.cc'; else $(CYGPATH_W) '$(srcdir)/read_sync.cc'; fi`; \ 338 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/network-read_sync.Tpo" "$(DEPDIR)/network-read_sync.Po"; else rm -f "$(DEPDIR)/network-read_sync.Tpo"; exit 1; fi 339 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='read_sync.cc' object='network-read_sync.obj' libtool=no @AMDEPBACKSLASH@ 340 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 341 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-read_sync.obj `if test -f 'read_sync.cc'; then $(CYGPATH_W) 'read_sync.cc'; else $(CYGPATH_W) '$(srcdir)/read_sync.cc'; fi` 342 343 network-write_sync.o: write_sync.cc 344 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-write_sync.o -MD -MP -MF "$(DEPDIR)/network-write_sync.Tpo" -c -o network-write_sync.o `test -f 'write_sync.cc' || echo '$(srcdir)/'`write_sync.cc; \ 345 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/network-write_sync.Tpo" "$(DEPDIR)/network-write_sync.Po"; else rm -f "$(DEPDIR)/network-write_sync.Tpo"; exit 1; fi 346 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='write_sync.cc' object='network-write_sync.o' libtool=no @AMDEPBACKSLASH@ 347 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 348 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-write_sync.o `test -f 'write_sync.cc' || echo '$(srcdir)/'`write_sync.cc 349 350 network-write_sync.obj: write_sync.cc 351 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-write_sync.obj -MD -MP -MF "$(DEPDIR)/network-write_sync.Tpo" -c -o network-write_sync.obj `if test -f 'write_sync.cc'; then $(CYGPATH_W) 'write_sync.cc'; else $(CYGPATH_W) '$(srcdir)/write_sync.cc'; fi`; \ 352 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/network-write_sync.Tpo" "$(DEPDIR)/network-write_sync.Po"; else rm -f "$(DEPDIR)/network-write_sync.Tpo"; exit 1; fi 353 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='write_sync.cc' object='network-write_sync.obj' libtool=no @AMDEPBACKSLASH@ 354 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 355 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-write_sync.obj `if test -f 'write_sync.cc'; then $(CYGPATH_W) 'write_sync.cc'; else $(CYGPATH_W) '$(srcdir)/write_sync.cc'; fi` 321 356 322 357 network-base_object.o: $(MAINSRCDIR)/lib/lang/base_object.cc -
branches/network/src/subprojects/network/network_unit_test.cc
r5822 r5829 12 12 13 13 #include "simple_sync.h" 14 #include "read_sync.h" 14 15 15 16 int verbose = 4; … … 25 26 printf(" --server [port number] creates a test server\n"); 26 27 printf(" --client [address] [port] connects to a server\n"); 28 printf(" --listen [address] [port] just listens to this connection"); 27 29 printf("\n"); 28 30 } … … 76 78 77 79 #define _N_ELEMENTS 212994 80 78 81 char sendbuf[_N_ELEMENTS+1]; 79 82 char recvbuf[_N_ELEMENTS+1]; … … 131 134 132 135 /* create the network manager */ 133 NetworkManager* nm = new NetworkManager();136 NetworkManager* nm = NetworkManager::getInstance(); 134 137 135 138 /* initialize the network manager */ … … 143 146 int error = SDLNet_ResolveHost(&ip, "127.0.0.1", port); 144 147 //SDLNet_ResolveHost(&ip, "localhost", port); 145 if(error == -1) printf("\n\nerror on address resolution, program inconsistancy\n\n"); 148 if(error == -1) 149 printf("\n\nerror on address resolution, program inconsistancy\n\n"); 146 150 nm->establishConnection(ip, *clientSync); 147 151 /* adding some break for connection setup */ … … 149 153 150 154 /* synchronize the data 1 time (increment for longer tests) */ 151 for( int i = 0; i < 3; i++) { 155 for( int i = 0; i < 3; i++) 156 { 152 157 nm->synchronize(); 153 158 /* simulate the network delay */ … … 177 182 int startServer(int argc, char** argv) 178 183 { 179 if( argc <= 2) { 184 if( argc <= 2) 185 { 180 186 printf(" Wrong arguments try following notations:\n"); 181 187 printf(" --server [port number]\n"); … … 186 192 printf("Starting Server on port %i\n", port); 187 193 188 NetworkManager* netMan = new NetworkManager();194 NetworkManager* netMan = NetworkManager::getInstance(); 189 195 Synchronizeable* ss = new SimpleSync("Server\0"); 190 196 191 //NetworkStream* server = new NetworkStream(port, ss, NET_SERVER);192 197 netMan->createServer(*ss, port); 193 198 SDL_Delay(20); 194 199 195 for(;;) { 200 for(;;) 201 { 196 202 netMan->synchronize(); 197 203 SDL_Delay(500); 198 204 } 205 206 delete netMan; 207 delete ss; 208 209 199 210 return 0; 200 211 } … … 203 214 int startClient(int argc, char** argv) 204 215 { 205 if( argc < 3) { 216 if( argc < 3) 217 { 206 218 printf(" Wrong arguments try following notations:\n"); 207 219 printf(" --client [server ip] [port number]\n"); 208 printf(" -- server[server name] [port number]\n");220 printf(" --client [server name] [port number]\n"); 209 221 return 0; 210 222 } … … 216 228 IPaddress ip; 217 229 int error = SDLNet_ResolveHost(&ip, name, port); 218 //SDLNet_ResolveHost(&ip, "localhost", port);219 if(error == -1)printf("\n\nerror on address resolution, program inconsistancy\n\n");220 221 NetworkManager* netMan = new NetworkManager();230 if(error == -1) 231 printf("\n\nerror on address resolution, program inconsistancy\n\n"); 232 233 NetworkManager* netMan = NetworkManager::getInstance(); 222 234 Synchronizeable* ss = new SimpleSync("Client\0"); 223 235 224 236 netMan->establishConnection(ip, *ss); 225 237 226 for(;;) { 238 for(;;) 239 { 227 240 netMan->synchronize(); 228 241 SDL_Delay(500); 229 242 } 230 243 231 //NetworkStream* client = new NetworkStream(ip, ss, NET_CLIENT); 244 245 delete netMan; 246 delete ss; 247 248 return 0; 249 } 250 251 252 253 int startListen(int argc, char** argv) 254 { 255 if( argc < 3) 256 { 257 printf(" Wrong arguments try following notations:\n"); 258 printf(" --listen [server ip] [port number]\n"); 259 printf(" --listen [server name] [port number]\n"); 260 return 0; 261 } 262 263 char* name = argv[2]; 264 int port = atoi(argv[3]); 265 printf("Connecting to %s, on port %i\n", name, port); 266 267 IPaddress ip; 268 int error = SDLNet_ResolveHost(&ip, name, port); 269 if(error == -1) 270 printf("\n\nerror on address resolution, program inconsistancy\n\n"); 271 272 NetworkManager* netMan = NetworkManager::getInstance(); 273 Synchronizeable* ss = new ReadSync("WriteSync\0"); 274 275 netMan->establishConnection(ip, *ss); 276 277 for(;;) 278 { 279 netMan->synchronize(); 280 SDL_Delay(10); 281 } 232 282 233 283 … … 253 303 { 254 304 //else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true; 255 if (! strcmp( "--sockettest", argv[i]) || !strcmp("-st", argv[i])) return testSocket(argc, argv); 256 else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-ft", argv[i])) return testFramework(argc, argv); 257 else if (! strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) return startServer(argc, argv); 258 else if (! strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) return startClient(argc, argv); 305 if (! strcmp( "--sockettest", argv[i]) || !strcmp("-st", argv[i])) 306 return testSocket(argc, argv); 307 else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-ft", argv[i])) 308 return testFramework(argc, argv); 309 else if (! strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) 310 return startServer(argc, argv); 311 else if (! strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) 312 return startClient(argc, argv); 313 else if (! strcmp( "--listen", argv[i]) || !strcmp("-l", argv[i])) 314 return startListen(argc, argv); 259 315 } 260 316 -
branches/network/src/subprojects/network/simple_sync.cc
r5822 r5829 86 86 * read data from Synchronizeable 87 87 */ 88 int SimpleSync::readBytes(byte* data) const88 int SimpleSync::readBytes(byte* data) 89 89 { 90 90 PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength); -
branches/network/src/subprojects/network/simple_sync.h
r5822 r5829 17 17 18 18 virtual void writeBytes(const byte* data, int length); 19 virtual int readBytes(byte* data) const;19 virtual int readBytes(byte* data); 20 20 21 21
Note: See TracChangeset
for help on using the changeset viewer.