-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.py
More file actions
48 lines (34 loc) · 1.1 KB
/
client.py
File metadata and controls
48 lines (34 loc) · 1.1 KB
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
39
40
41
42
43
44
45
46
47
48
print("""\n\n
__ __ __ ____
_____/ /_ ____ _/ /_ / /_ ___ / / /
/ ___/ __ \/ __ `/ __/ / __ \/ _ \/ / /
/ /__/ / / / /_/ / /_ / / / / __/ / /
\___/_/ /_/\__,_/\__/ /_/ /_/\___/_/_/
\n\n\n""")
import time
import socket
import sys
socket_server = socket.socket()
server_host = socket.gethostname()
ip = socket.gethostbyname(server_host)
port = 8080
print('This is your IP address: ',ip)
server_host = input('Enter host\'s IP address: ')
name = input('Enter your username: ')
socket_server.connect((server_host, port))
socket_server.send(name.encode())
server_name = socket_server.recv(1024)
server_name = server_name.decode()
print(server_name,' has joined...\n\n')
def send():
message = (socket_server.recv(1024)).decode()
print(server_name, ":", message)
message = input("\nMe : ")
socket_server.send(message.encode())
while True:
try:
send()
except:
print("there is a Problem in the script!")
time.sleep(5)
exit()