Skip to content

Instantly share code, notes, and snippets.

@basith374
Created November 4, 2018 16:06
Show Gist options
  • Save basith374/dd5f432b0e75ea188d63cdb8e977e3d8 to your computer and use it in GitHub Desktop.
Save basith374/dd5f432b0e75ea188d63cdb8e977e3d8 to your computer and use it in GitHub Desktop.
socket connect
import socket
import sys
if len(sys.argv) < 2:
print('usage: %s <deviceid> <cmd> [<params>]' % (sys.argv[0]))
exit()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('13.250.41.251', 8008))
deviceid = int(sys.argv[1])
cmd = int(sys.argv[2])
data = bytearray([200])
data = data + deviceid.to_bytes(4, 'big')
data.append(cmd)
if cmd == 4 or cmd == 5:
data.append(int(sys.argv[3]))
else:
for i in sys.argv[3:]:
data = data + int(i).to_bytes(4, 'big')
print(data)
s.send(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment