udp example
This commit is contained in:
parent
4aa84b02bf
commit
2674003f7c
21
udp_socket_server.py
Executable file
21
udp_socket_server.py
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import socket
|
||||
import thread
|
||||
|
||||
#host = socket.gethostname()
|
||||
host = "192.168.178.21"
|
||||
port = 5005
|
||||
|
||||
def main():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.bind((host,port))
|
||||
|
||||
while 1:
|
||||
data, addr = s.recvfrom(1024)
|
||||
print data
|
||||
print addr
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user