forked from cyhe66/CodeB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientpy2.py
More file actions
38 lines (30 loc) · 994 Bytes
/
Copy pathclientpy2.py
File metadata and controls
38 lines (30 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import socket
import sys
def run(user, password, *commands):
HOST, PORT = "codebb.cloudapp.net", 17429
data=user + " " + password + "\n" + "\n".join(commands) + "\nCLOSE_CONNECTION\n"
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
sock.sendall(data)
sfile = sock.makefile()
rline = sfile.readline()
while rline:
print(rline.strip())
rline = sfile.readline()
finally:
sock.close()
def subscribe(user, password):
HOST, PORT = "codebb.cloudapp.net", 17429
data=user + " " + password + "\nSUBSCRIBE\n"
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
sock.sendall(data)
sfile = sock.makefile()
rline = sfile.readline()
while rline:
print(rline.strip())
rline = sfile.readline()
finally:
sock.close()