generated from PlexSheep/rs-base
33 lines
602 B
Python
33 lines
602 B
Python
|
from io import BufferedRWPair
|
||
|
import socket
|
||
|
|
||
|
REMOTE = "127.0.0.1"
|
||
|
PORT = 1337
|
||
|
|
||
|
def main() -> int:
|
||
|
s = socket.socket()
|
||
|
s.connect((REMOTE, PORT))
|
||
|
sf: BufferedRWPair = s.makefile('rwb')
|
||
|
|
||
|
pl = int.to_bytes(1337, 2, "big")
|
||
|
|
||
|
_ = send(sf, pl)
|
||
|
|
||
|
sf.close()
|
||
|
return 0
|
||
|
|
||
|
def send(sf: BufferedRWPair, msg: bytes) -> int:
|
||
|
print(f"> {msg.hex()}")
|
||
|
sent: int = sf.write(msg + b"\n")
|
||
|
sf.flush()
|
||
|
return sent
|
||
|
|
||
|
def recv(sf: BufferedRWPair) -> bytes:
|
||
|
response = sf.readline().strip()
|
||
|
print(f"< {response}")
|
||
|
return response
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
exit(main())
|