Beispiel #1
0
 def test_udpsocket_broadcast_IPv4(self):
     l = socket.socket(ip.PF_INET, socket.SOCK_DGRAM)
     l.bind(("0.0.0.0",0))
     addr, port = l.getsockname()[:2]
     s = UdpSocket()
     n = s.sendTo(self.data, "255.255.255.255", int(port))
     self.assertEqual(n, len(self.data))
     time.sleep(_sec)
     data, source = l.recvfrom(1024)
     self.assertEqual(data, self.data)
     l.close()
Beispiel #2
0
 def test_udpsocket_loopback_IPv6(self):
     l = socket.socket(ip.PF_INET6, socket.SOCK_DGRAM)
     l.bind(("::1",0))
     addr, port = l.getsockname()[:2]
     s = UdpSocket()
     n = s.sendTo(self.data, "::1", int(port))
     self.assertEqual(n, len(self.data))
     time.sleep(_sec)
     data, source = l.recvfrom(1024)
     self.assertEqual(data, self.data)
     l.close()
Beispiel #3
0
 def test_udpsocket_localhost_IPv6(self):
     try:
         hostaddress, hostport = ip.resolve("localhost", 0, ip.PF_INET6)
     except Exception:
         hostaddress, hostport = None, 0
     if hostaddress is not None:
         l = socket.socket(ip.PF_INET6, socket.SOCK_DGRAM)
         l.bind(("localhost",0))
         addr, port = l.getsockname()[:2]
         s = UdpSocket()
         n = s.sendTo(self.data, "localhost", int(port), ip.PF_INET6)
         self.assertEqual(n, len(self.data))
         time.sleep(_sec)
         data, source = l.recvfrom(1024)
         self.assertEqual(data, self.data)
         l.close()