Changeset 5811 in orxonox.OLD for branches/network/src/subprojects
- Timestamp:
- Nov 28, 2005, 11:00:57 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/subprojects/network/network_unit_test.cc
r5808 r5811 166 166 167 167 168 169 /** 170 * 171 * @param argc 172 * @param argv 173 * @return 174 */ 175 int startServer(int argc, char** argv) 176 { 177 if( argc <= 2) { 178 printf(" Wrong arguments try following notations:\n"); 179 printf(" --server [port number]\n"); 180 return 0; 181 } 182 183 int port = atoi(argv[2]); 184 printf("Starting Server on port %i\n", port); 185 186 NetworkManager* netMan = new NetworkManager(); 187 Synchronizeable* ss = new SimpleSync("Server\0"); 188 189 //NetworkStream* server = new NetworkStream(port, ss, NET_SERVER); 190 netMan->createServer(*ss, port); 191 192 return 0; 193 } 194 195 196 int startClient(int argc, char** argv) 197 { 198 if( argc < 3) { 199 printf(" Wrong arguments try following notations:\n"); 200 printf(" --client [server ip] [port number]\n"); 201 printf(" --server [server name] [port number]\n"); 202 return 0; 203 } 204 205 char* name = argv[2]; 206 int port = atoi(argv[3]); 207 printf("Connecting to %s, on port %i\n", name, port); 208 209 IPaddress ip; 210 int error = SDLNet_ResolveHost(&ip, name, port); 211 //SDLNet_ResolveHost(&ip, "localhost", port); 212 if(error == -1) printf("\n\nerror on address resolution, program inconsistancy\n\n"); 213 214 NetworkManager* netMan = new NetworkManager(); 215 Synchronizeable* ss = new SimpleSync("Client\0"); 216 217 netMan->establishConnection(ip, *ss); 218 219 220 //NetworkStream* client = new NetworkStream(ip, ss, NET_CLIENT); 221 222 223 delete netMan; 224 delete ss; 225 226 return 0; 227 } 228 229 230 168 231 /** 169 232 * … … 174 237 int main(int argc, char** argv) 175 238 { 239 int i; 176 240 // here the pre-arguments are loaded, these are needed to go either to orxonx itself, Help, or Benchmark. 177 int i;178 241 for(i = 1; i < argc; ++i) 179 242 { 180 243 //else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true; 181 if (! strcmp( "--sockettest", argv[i]) || !strcmp("-s", argv[i])) return testSocket(argc, argv); 182 else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-f", argv[i])) return testFramework(argc, argv); 244 if (! strcmp( "--sockettest", argv[i]) || !strcmp("-st", argv[i])) return testSocket(argc, argv); 245 else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-ft", argv[i])) return testFramework(argc, argv); 246 else if (! strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) return startServer(argc, argv); 247 else if (! strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) return startClient(argc, argv); 183 248 } 184 249
Note: See TracChangeset
for help on using the changeset viewer.