-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
38 lines (29 loc) · 798 Bytes
/
client.py
File metadata and controls
38 lines (29 loc) · 798 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 time
HOST = '127.0.0.1' # The server's hostname or IP address
PORT = 65432 # The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
cadena=str(input("-->"))
cadenabytes=cadena.encode()
s.sendall(cadenabytes)#objeto tipo bytes
data = s.recv(1024)
if not data:
break
if(cadenabytes!=data):
print(repr(data))
'''
import socket
s = socket.socket()
host = socket.gethostname()
port = 12221
s.connect((host, port))
print ('Connected to', host)
while True:
z = str(input("Enter something for the server: "))
s.send(z.encode())
# Halts
print ('[Waiting for response...]')
print (s.recv(1024) )
'''