IBR-DTNSuite
0.8
|
00001 /* 00002 * UnicastSocket.cpp 00003 * 00004 * Created on: 28.06.2010 00005 * Author: morgenro 00006 */ 00007 00008 #include "ibrcommon/net/UnicastSocket.h" 00009 #include "ibrcommon/net/vsocket.h" 00010 #include <netdb.h> 00011 00012 namespace ibrcommon 00013 { 00014 UnicastSocket::UnicastSocket() 00015 { 00016 } 00017 00018 UnicastSocket::~UnicastSocket() 00019 { 00020 } 00021 00022 void UnicastSocket::bind(int port, const vinterface &iface) 00023 { 00024 std::list<vaddress> list = iface.getAddresses(); 00025 for (std::list<vaddress>::const_iterator iter = list.begin(); iter != list.end(); iter++) 00026 { 00027 if (!iter->isBroadcast()) 00028 { 00029 bind(port, *iter); 00030 } 00031 } 00032 } 00033 00034 void UnicastSocket::bind(int port, const vaddress &address) 00035 { 00036 _socket.bind(address, port, SOCK_DGRAM); 00037 } 00038 00039 void UnicastSocket::bind() 00040 { 00041 _socket.bind(0, SOCK_DGRAM); 00042 } 00043 }