socket scripts added

This commit is contained in:
Mari Wahl 2014-12-16 12:58:22 -05:00
parent d01824f424
commit ac171e1195
5 changed files with 159 additions and 7 deletions

View file

@ -0,0 +1,31 @@
#!/usr/bin/env python
__author__ = "bt3"
import socket
# Defining constants
HOST = '127.0.0.1'
PORT = 80
DATA = 'AAABBBCCC'
def udp_client():
# Create a socket object
# AF_INET parameter: to use standard IPv4 address
# SOCK_DGRAM: to indicate udp client
client = socket.socket( socket.AF_INET, socket.SOCK_DGRAM)
# Send data
client.sendto(DATA, ( HOST, PORT ))
# Receive some data
data, addr = client.recvfrom(4096)
print data, addr
if __name__ == '__main__':
udp_client()