Skip to content

Instantly share code, notes, and snippets.

@spiralray
Created May 12, 2018 13:45
Show Gist options
  • Save spiralray/6a0356abb03996b919e144df429b7649 to your computer and use it in GitHub Desktop.
Save spiralray/6a0356abb03996b919e144df429b7649 to your computer and use it in GitHub Desktop.
import socket
from contextlib import closing
def main():
host = '192.168.15.10'
port = 12345
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
with closing(sock):
message = 'Hello world'.encode('utf-8')
print(message)
sock.sendto(message, (host, port))
return
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment