sec-pentesting-toolkit/Network_and_802.11/socket/udp_client.py
2014-12-16 23:58:01 -05:00

31 lines
527 B
Python
Executable file

#!/usr/bin/env python
__author__ = "bt3"
import socket
# Defining constants
HOST = '127.0.0.1'
PORT = 9000
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()