-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTcpClient.py
More file actions
30 lines (22 loc) · 716 Bytes
/
TcpClient.py
File metadata and controls
30 lines (22 loc) · 716 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
import socket
# 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 = ('10.223.31.201', 9001)
print('[+] Connecting to %s Port %s' % server_address)
sock.connect(server_address)
try:
message = 'BUZZER_SLBR-041_PRESSED'
print('[+] Sending "%s"' % message)
sock.sendall(message.encode('latin-1'))
# # Look for the response
# amount_received = 0
# amount_expected = len(message)
#
# while amount_received < amount_expected:
# data = sock.recv(16)
# amount_received += len(data)
# print
# '[+] Received "%s"' % data
finally:
sock.close()