Changeset 7459 for code/trunk/src/libraries/network/LANDiscovery.cc
- Timestamp:
- Sep 17, 2010, 12:48:29 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/ipv6 (added) merged: 7293-7295,7320,7322,7328-7330,7376-7378,7381-7382,7384-7387,7389-7394,7396-7397,7402,7411,7414,7433,7435,7437-7438,7442-7443,7453-7454
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/LANDiscovery.cc
r7284 r7459 42 42 LANDiscovery::LANDiscovery() 43 43 { 44 this->host_ = enet_host_create(NULL, 10, 0, 0 ); 44 this->host_ = enet_host_create(NULL, 10, 0, 0, 0 ); 45 if ( this->host_ == NULL ) 46 COUT(1) << "LANDiscovery: host_ == NULL" << std::endl; 45 47 } 46 48 … … 53 55 { 54 56 this->servers_.clear(); 57 ENetPeer* peer; 55 58 ENetAddress address; 56 enet_address_set_host(&address, "255.255.255.255");59 memset(&address, 0, sizeof(ENetAddress)); 57 60 address.port = LAN_DISCOVERY_PORT; 58 61 59 ENetPeer* peer; 60 peer = enet_host_connect(this->host_, &address, 0); 62 /* TODO: check for availability of each protocol */ 63 /* IPv4 */ 64 address.host = ENET_HOST_BROADCAST; 65 peer = enet_host_connect(this->host_, &address, 0, 0); 66 if (peer == NULL) 67 COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl; 68 69 /* IPv6 */ 70 enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group 71 peer = enet_host_connect(this->host_, &address, 0, 0); 72 if (peer == NULL) 73 COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl; 61 74 62 75 ENetEvent event; … … 67 80 case ENET_EVENT_TYPE_CONNECT: 68 81 { 69 COUT( 0) << "connect from server: " << event.peer->address.host <<endl;82 COUT(4) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << std::endl; 70 83 ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE); 71 84 enet_peer_send(event.peer, 0, packet); … … 75 88 { 76 89 packet::ServerInformation info(&event); 77 COUT( 0) << "received server information; name: " << info.getServerName() << ", IP: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;90 COUT(3) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl; 78 91 std::vector<packet::ServerInformation>::iterator it; 79 92 for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
Note: See TracChangeset
for help on using the changeset viewer.