Bottom Page

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 making a multiplayer game and clients to connect it.
The Problem is that I keep getting this error and I don't know why Angry :

[WinError 10053] An established connection was aborted by the software in your host machine

network.py
import socket

class Network:
    def __init__(self):
        self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server = "..."
        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 = "..."
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(2)
print("Waiting for connection, Server Started")


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

            if not data:
                print("Disconnected")
                break
            else:
                print("Received: ", reply)
                print("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 Process finished with exit code 0
server.py output:
Output:
Waiting for connection, Server Started Connected to: ('192.168...', ...) Lost connection
I only get the error when I have the lines 29/30 in network.py.

Thanks in Advance!

(Note: I removed the IP adresses, etc just because I don't want you to see them. They're present in the real code.)

Edit: I just realised that there's a Forum for networking. I'm sorry!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Issues in Chat App for Local Network iMuny 2 209 Aug-19-2019, 10:25 AM
Last Post: iMuny
  socket.gaierror: [Errno 11001] Johnygo 3 131 Aug-07-2019, 02:49 PM
Last Post: Johnygo
  Soft Access Point & Socket Data Streaming groger57 1 130 Aug-01-2019, 02:53 PM
Last Post: groger57
  Send raw string via socket with out any changes john36 18 472 Aug-01-2019, 07:54 AM
Last Post: john36
  Question concerning function of a a socket pkm 4 1,133 Jun-04-2019, 07:48 AM
Last Post: DeaD_EyE
  socket.gaierror: [Errno -2] Name or service not known seokangwoo99 5 495 May-25-2019, 02:36 PM
Last Post: DeaD_EyE
  socket programming ConnectionRefusedError error srm 3 355 May-16-2019, 08:07 PM
Last Post: LavaCreeperKing
  creation of an application for lora sever network moez 3 313 Apr-18-2019, 11:05 AM
Last Post: buran
  Socket reading script Will86 4 407 Apr-17-2019, 06:57 AM
Last Post: Will86
  Server and Network (socket) [WinError 10053] SheeppOSU 2 565 Apr-13-2019, 09:23 PM
Last Post: SheeppOSU

Forum Jump:


Users browsing this thread: 1 Guest(s)