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 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
Age Doesn't Matter, Your Passion Does
- Shreya Jain
Quote
#2
Line 27 of server.py is a syntax error. Which would cause the server to close the connection (on line 39).
Quote
#3
Oh! oops, Thx
Age Doesn't Matter, Your Passion Does
- Shreya Jain
Quote

Top Page

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

Forum Jump:


Users browsing this thread: 1 Guest(s)