Changeset 96
- Timestamp:
- 02/12/09 10:13:34 (15 years ago)
- Location:
- vtcross/trunk/CR_shell/src
- Files:
-
- 2 removed
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/CR_shell/src/main_cognitive_radio.cpp
r95 r96 2 2 #include <sys/types.h> 3 3 #include <sys/wait.h> 4 #include <sys/socket.h> 5 #include <netinet/in.h> 6 #include <netdb.h> 4 7 #include "tinyxml.h" 5 8 #include "tinystr.h" 6 #include "socket/ServerSocket.h" 7 #include "socket/SocketException.h" 9 #include <arpa/inet.h> 10 //#include "socket/ServerSocket.h" 11 //#include "socket/SocketException.h" 8 12 9 13 using namespace std; … … 471 475 // Start socket server 472 476 int sockfd, newsockfd, clilen; 473 int peer_len = sizeof(struct sockaddr);474 477 struct sockaddr_in serv_addr, cli_addr; 475 struct sockaddr_in peer; 476 478 char str[20]; 477 479 478 480 // Setup server socket connection … … 497 499 error("ERROR on accept"); 498 500 499 if(getpeername(newsockfd, (struct sockaddr *) &peer, (socklen_t*)&peer_len) == -1) { 500 perror("getpeername() failed"); 501 return -1; 502 } 503 504 printf("Received a connection from a Cognitive Engine with IP address: %s\n\n",inet_ntoa(peer.sin_addr)); 501 inet_ntop(AF_INET,&(cli_addr.sin_addr),str,20); 502 printf("Received a connection from a Cognitive Engine with IP address: %s\n\n",str); 505 503 506 504 // Begin parsing the messages