Last active
August 22, 2016 04:07
-
-
Save mhtsai1010/62c56e96d5d58325c06a to your computer and use it in GitHub Desktop.
Python: udp client sockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import socket | |
target_host = "127.0.0.1" | |
target_port = 80 | |
# create a socket object | |
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
# send some data | |
client.sendto("input some data here", (target_host, target_port)) | |
# receive some data | |
(data, addr) = client.recvfrom(4096) | |
# print response | |
print data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment