Python udp connection: Unterschied zwischen den Versionen

Aus xinux.net
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „<pre> #!/usr/bin/python import socket UDP_IP = "127.0.0.1" UDP_PORT = 999 MESSAGE = "Hello, World!" print "UDP target IP:", UDP_IP print "UDP target port:",…“)
 
Zeile 17: Zeile 17:
 
=Links=
 
=Links=
 
*https://wiki.python.org/moin/UdpCommunication
 
*https://wiki.python.org/moin/UdpCommunication
 +
*https://tutorialedge.net/python/udp-client-server-python/

Version vom 18. Dezember 2017, 17:56 Uhr

#!/usr/bin/python
import socket

UDP_IP = "127.0.0.1"
UDP_PORT = 999
MESSAGE = "Hello, World!"

print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE

sock = socket.socket(socket.AF_INET, # Internet
             socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

Links