-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathclient.py
More file actions
30 lines (24 loc) · 700 Bytes
/
client.py
File metadata and controls
30 lines (24 loc) · 700 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
import socket
# create an ipv4 (AF_INET) socket object using the tcp protocol (SOCK_STREAM)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect the client
# client.connect((target, port))
client.connect(('127.0.0.1', 1233))
response = client.recv(2048)
# Input UserName
name = input(response.decode())
client.send(str.encode(name))
response = client.recv(2048)
# Input Password
password = input(response.decode())
client.send(str.encode(password))
''' Response : Status of Connection :
1 : Registeration successful
2 : Connection Successful
3 : Login Failed
'''
# Receive response
response = client.recv(2048)
response = response.decode()
print(response)
client.close()