Last active
May 12, 2022 08:34
-
-
Save wisnubaldas/8bcedb8dd2f3739c722e4c1ed8e44efa to your computer and use it in GitHub Desktop.
Revisions
-
wisnubaldas renamed this gist
May 12, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wisnubaldas created this gist
May 12, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ import socket import sys # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Connect the socket to the port where the server is listening server_address = ('192.168.123.49', 5000) print(sys.stderr, 'connecting to %s port %s' % server_address) sock.connect(server_address) try: sock.setblocking(True) # Send data # message = "02 00 31 03 36" arr = bytes.fromhex('02 00 31 03 36') print(len(arr)) print(sys.stderr, 'sending "%s"' % arr) sock.send(arr) data = sock.recv(9) print(sys.stderr, 'received "%s"' % data) # Look for the response # amount_received = 0 # amount_expected = len(arr) # print(amount_expected) # while amount_received < amount_expected: # data = sock.recv(14) # amount_received += len(data) # print(sys.stderr, 'received "%s"' % data) finally: print(sys.stderr, 'closing socket') sock.close()