Skip to content

Instantly share code, notes, and snippets.

@shubham7298
Created August 30, 2018 11:54
Show Gist options
  • Save shubham7298/e0cf2ddd40fa4556b32cda18034e763f to your computer and use it in GitHub Desktop.
Save shubham7298/e0cf2ddd40fa4556b32cda18034e763f to your computer and use it in GitHub Desktop.
Socket Programming in Python(client)
# Save as client.py
# Message Sender
import os
from socket import *
host = "" # set to IP address of target computer
port = 13000
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
while True:
data = raw_input("Enter message to send or type 'exit': ")
UDPSock.sendto(data, addr)
if data == "exit":
break
UDPSock.close()
os._exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment