28 lines
633 B
Python
Executable File
28 lines
633 B
Python
Executable File
#!/usr/bin/env python
|
|
import socket
|
|
from os import system, name
|
|
from time import sleep
|
|
|
|
def clear():
|
|
if name == 'nt':
|
|
_ = system('cls')
|
|
else:
|
|
_ = system('clear')
|
|
|
|
#clear()
|
|
print("CLIENT Programm")
|
|
print("Lokale IP-Adresse: " + socket.gethostbyname(socket.gethostname()))
|
|
ip = input("IP-Adresse: ")
|
|
port = int(input("Port: "))
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.connect((ip, port))
|
|
|
|
try:
|
|
while True:
|
|
nachricht = input("Nachricht: ")
|
|
s.send(nachricht.encode())
|
|
antwort = s.recv(1024)
|
|
print("[{}] {}".format(ip, antwort.decode()))
|
|
finally:
|
|
s.close()
|