-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
28 lines (20 loc) · 818 Bytes
/
Copy pathclient.py
File metadata and controls
28 lines (20 loc) · 818 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
#we add socket library!!
import socket
#we create host and port, assign ip address for host and assign port number for port
host = "127.0.0.1"
port = 10001
#we create object and our object IPV4 and TCP
client_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#we connect host and port
client_socket.connect((host, port))
#we create message and send to server
message = input(" ")
#we create loop and if user input "quit,Quit, QUİT" loop finish
while message.lower().strip() != "quit":
#we send to message and we encode message that means from strings to byte(10101001)
client_socket.send(message.encode())
#server send to message and client decode message
data = client_socket.recv(1024).decode()
print("Server Response: ",str(data))
message = input(" ")
client_socket.close()