Changeset 64 for vtcross/branches/trnewman/CR_shell
- Timestamp:
- 11/20/08 15:25:32 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp
r63 r64 227 227 n = recv(socketfd,buffer,255,0); 228 228 if (n < 0) error("ERROR reading from socket"); 229 if (n == 0) error("Client has closed the connection."); 229 if (n == 0) { 230 printf("Client has closed the connection.\n"); 231 return; 232 } 230 233 231 234 // Print message … … 257 260 listen(sockfd,5); 258 261 clilen = sizeof(cli_addr); 259 newsockfd = accept(sockfd, 260 (struct sockaddr *) &cli_addr, 261 (socklen_t*)&clilen); 262 if (newsockfd < 0) 263 error("ERROR on accept"); 264 265 // Begin parsing the messages 266 StartMessageParser(newsockfd); 267 262 263 while(1) { 264 newsockfd = accept(sockfd, 265 (struct sockaddr *) &cli_addr, 266 (socklen_t*)&clilen); 267 if (newsockfd < 0) 268 error("ERROR on accept"); 269 270 // Begin parsing the messages 271 StartMessageParser(newsockfd); 272 } 268 273 return 0; 269 274 } … … 275 280 // CognitiveEngineShell Shell; 276 281 string pFilename; 282 int pid; 277 283 278 284 Utility * uList[10]; … … 300 306 cout << "Configuration file parsing completed." << endl; 301 307 302 // Open cognitive engine port 303 StartShell(30000); 304 305 // Open policy engine port 306 // StartShell(30001); 308 pid = fork(); 309 if(pid == 0) { 310 // In child process - open policy engine port. 311 StartShell(30001); 312 } else { 313 // In parent process - open cognitive engine port. 314 StartShell(30000); 315 } 316 307 317 308 318 return 1;