Skip to content

Instantly share code, notes, and snippets.

@Merwanski
Created November 24, 2021 13:52
Show Gist options
  • Save Merwanski/3ac87444073811d62470ff49545bf7d2 to your computer and use it in GitHub Desktop.
Save Merwanski/3ac87444073811d62470ff49545bf7d2 to your computer and use it in GitHub Desktop.
client.py
#!/usr/bin/env python3
import sys
from socket import socket, AF_INET, SOCK_DGRAM
# TODO update this part with the IP address of the server and port number used
SERVER_IP = '172.19.0.3'
PORT_NUMBER = 5000
SIZE = 1024
print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP, PORT_NUMBER))
mySocket = socket( AF_INET, SOCK_DGRAM )
myMessage = "Hello!"
myMessage1 = ""
i = 0
while i < 10:
mySocket.sendto(myMessage.encode('utf-8'),(SERVER_IP,PORT_NUMBER))
i = i + 1
mySocket.sendto(myMessage1.encode('utf-8'),(SERVER_IP,PORT_NUMBER))
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment