Skip to content

Commit d43730a

Browse files
committed
Create udp_client.py
1 parent 890a76e commit d43730a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

socket/udp_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
'a socket example which send echo message to server.'
5+
6+
import socket
7+
8+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
9+
for data in ['Michael', 'Tracy', 'Sarah']:
10+
# 发送数据:
11+
s.sendto(data, ('127.0.0.1', 9999))
12+
# 接收数据:
13+
print s.recv(1024)
14+
s.close()

0 commit comments

Comments
 (0)