Python Forum
Server and Network (socket) [WinError 10053]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Server and Network (socket) [WinError 10053]
#1
I was watching a tutorial on using socket to create servers and connect clients to make a multiplayer game. The problem is I keep getting this error. It's not an error from python, it's print from socket.error at "Network.py" on line 25. Also I only get the error when I have lines 29 and 28 in Network.py. Thx in advance.

Network.py
import socket

class Network():
    def __init__(self):
        self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server = '192.168.1.96'
        self.port = 5555
        self.addr = (self.server, self.port)
        self.id = self.connect()
        print(self.id)

    def connect(self):
        try:
            self.client.connect(self.addr)
            return self.client.recv(2048).decode()
        except:
            pass

    def send(self, data):
        try:
            self.client.send(str.encode(data))
            return self.client.recv(2048).decode()
        
        except socket.error as e:
            print(e)

n = Network()
print(n.send('Hello'))
print(n.send('Working'))
server.py
import socket
from _thread import *
import sys

server = '192.168.1.96'
port = 5555

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
    s.bind((server, port))
except socket.error as e:
    str(e)


s.listen()
print('Waiting for connection, Server Started')

def threaded_client(conn):
    conn.send(str.encode('Connected'))
    reply = ''
    while True:
        try:
            data = conn.recieve(2048)
            reply = data.decode('utf-8')

            if notdata:
                print('Disconnected')
                break
            else:
                print('Received: ', reply)
                pritn('Sending: ', reply)

            conn.sendall(str.encode(reply))
        except:
            break

    print('Lost Connection')
    conn.close()


while True:
    conn, addr = s.accept()
    print('Connected to: ', addr)
    
    start_new_thread(threaded_client, (conn,))
Network.py output
Output:
Connected [WinError 10053] An established connection was aborted by the software in your host machine None [WinError 10053] An established connection was aborted by the software in your host machine None
server.py output
Output:
Waiting for connection, Server Started Connected to: ('192.168.1.96', 53737) Lost Connection
Reply
#2
Line 27 of server.py is a syntax error. Which would cause the server to close the connection (on line 39).
Reply
#3
Oh! oops, Thx
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,538 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  Socket server problem H84Gabor 0 1,248 Jun-21-2022, 12:14 AM
Last Post: H84Gabor
  [WinError 10057] lolloiltizio 0 4,970 Aug-10-2020, 05:57 PM
Last Post: lolloiltizio
  [Socket] Can a server be accessible from devices not in the same network? SheeppOSU 2 2,965 Jun-18-2020, 01:29 PM
Last Post: DeaD_EyE
  Writing socket server NewPy_thwan_Programmer 0 1,930 Feb-23-2020, 03:58 PM
Last Post: NewPy_thwan_Programmer
  Server and Network (socket) [WinError 10053] Timxxx 1 4,586 Aug-23-2019, 10:03 AM
Last Post: iMuny
  Async socket server and ports Pengwyn 1 11,869 Feb-28-2019, 12:13 AM
Last Post: DeaD_EyE
  Multi connection socket server help! MuntyScruntfundle 0 2,715 Feb-19-2019, 12:03 PM
Last Post: MuntyScruntfundle
  Multiple network socket servers? MuntyScruntfundle 1 2,494 Nov-13-2018, 03:46 PM
Last Post: wavic
  Send data BMP180 between client and server trought module socket smalhao 0 2,838 Jul-30-2018, 12:56 PM
Last Post: smalhao

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020