Skip to content

Instantly share code, notes, and snippets.

@amd64bit
Forked from glegoux/udpclient.py
Created April 20, 2018 04:34
Show Gist options
  • Save amd64bit/0f7cb81995ab638f33fbabd6aad9fd0f to your computer and use it in GitHub Desktop.
Save amd64bit/0f7cb81995ab638f33fbabd6aad9fd0f to your computer and use it in GitHub Desktop.

Revisions

  1. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion udpclient.py
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@
    UDP_PORT_SERVER = 8000
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
    print("Sending message '{}' to UDP server on {} port {} ...".format(message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(message.encode('utf-8'), (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))

  2. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion udpclient.py
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,6 @@
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print("Sending message '{}' UDP server on {} port {} ...".format(message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    print("Sending message '{}' to UDP server on {} port {} ...".format(message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(message.encode('utf-8'), (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))

  3. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -14,9 +14,9 @@

    UDP_IP_ADDRESS_SERVER = "127.0.0.1"
    UDP_PORT_SERVER = 8000
    message = "Hello, Server".encode('utf-8')
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print("Sending message '{}' UDP server on {} port {} ...".format(message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(message, (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(message.encode('utf-8'), (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))

  4. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -14,9 +14,9 @@

    UDP_IP_ADDRESS_SERVER = "127.0.0.1"
    UDP_PORT_SERVER = 8000
    message = "Hello, Server"
    message = "Hello, Server".encode('utf-8')

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print("Sending message '{}' UDP server on {} port {} ...".format(message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(bytes(message), (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(message, (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))

  5. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,6 @@
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print("Sending message '{}' UDP server on {} port {} ...", message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER)
    client.sendto(message, (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    print("Sending message '{}' UDP server on {} port {} ...".format(message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))
    client.sendto(bytes(message), (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))

  6. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion udpclient.py
    Original file line number Diff line number Diff line change
    @@ -18,5 +18,5 @@

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print("Sending message '{}' UDP server on {} port {} ...", message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER)
    client.sendto(message, (UDP_IP_ADDRESS, UDP_PORT_NO))
    client.sendto(message, (UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER))

  7. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion udpclient.py
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # Required that UDP server runs on 127.0.0.1 port 8000.
    # See Gist udpserver.py.
    #
    # Send UDD message to UDP server.
    # Send UDP message to UDP server.
    #
    # usage: python3 udpclient.py

  8. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,12 @@
    #
    # udpclient.py
    #
    # Required that UDP server runs on 127.0.0.1 port 8000.
    # See Gist udpserver.py.
    #
    # Send UDD message to UDP server.
    #
    # usage: python3 udpclient.py

    if __name__ == "__main__":
    import socket
  9. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion udpclient.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    #
    # udpclient.py
    #
    # # See Gist udpserver.py.
    # See Gist udpserver.py.

    if __name__ == "__main__":
    import socket
  10. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -12,5 +12,6 @@
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print("Sending message '{}' UDP server on {} port {} ...", message, UDP_IP_ADDRESS_SERVER, UDP_PORT_SERVER)
    client.sendto(message, (UDP_IP_ADDRESS, UDP_PORT_NO))

  11. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    #!/usr/bin/env python3
    #
    # udpclient.py
    #
    # # See Gist udpserver.py.

    if __name__ == "__main__":
    import socket
  12. @glegoux glegoux revised this gist Aug 29, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion udpclient.py
    Original file line number Diff line number Diff line change
    @@ -10,5 +10,5 @@
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    client.sendto(Message, (UDP_IP_ADDRESS, UDP_PORT_NO))
    client.sendto(message, (UDP_IP_ADDRESS, UDP_PORT_NO))

  13. @glegoux glegoux created this gist Aug 29, 2017.
    14 changes: 14 additions & 0 deletions udpclient.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/usr/bin/env python3
    #
    # udpclient.py

    if __name__ == "__main__":
    import socket

    UDP_IP_ADDRESS_SERVER = "127.0.0.1"
    UDP_PORT_SERVER = 8000
    message = "Hello, Server"

    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    client.sendto(Message, (UDP_IP_ADDRESS, UDP_PORT_NO))