Jun-10-2020, 07:59 PM
(This post was last modified: Jun-10-2020, 07:59 PM by omega_elite.)
Hi
I am new to python and am playing with some code that I got on an online course but am getting this error "ValueError: invalid literal for int() with base 10: 'terertsagdx'"...... I am connecting to the server with realterm and sending 'terertsagdx, as ascii but get the error and am not sure why ????
I am new to python and am playing with some code that I got on an online course but am getting this error "ValueError: invalid literal for int() with base 10: 'terertsagdx'"...... I am connecting to the server with realterm and sending 'terertsagdx, as ascii but get the error and am not sure why ????
import socket
import threading
HEADER = 64
PORT = 5050
SERVER = socket.gethostbyname(socket.gethostname())
ADDR = (SERVER, PORT)
FORMAT = 'utf-8'
DISCONNECT_MESSAGE = "!DISCONNECT"
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)
def handle_client(conn, addr):
print(f"[NEW CONNECTION] {addr} connected.")
connected = True
while connected:
msg = conn.recv(1024).decode(ascii)
print(msg)
conn.send("Msg received")
conn.close()
def start():
server.listen()
print(f"[LISTENING] Server is listening on {SERVER}")
while True:
conn, addr = server.accept()
thread = threading.Thread(target=handle_client, args=(conn, addr))
thread.start()
print(f"[ACTIVE CONNECTIONS] {threading.activeCount() - 1}")
print("[STARTING] server is starting...")
start()Thanks for any help
