Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7542429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:09:49+00:00 2026-05-30T08:09:49+00:00

I have been trying to implement a small SERVER – CLIENT app but ran

  • 0

I have been trying to implement a small SERVER – CLIENT app but ran in to a errrr:

socket.error: [Errno 10057] A request to send or receive data was
disallowed because the socket is not connected and (when sending on a
datagram socket using a sendto call) no address was supplied

Server:

class Server:
    gate = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host = socket.gethostname()
    port = 0
    file = ''

    def __init__(self, port):
        self.port = port
        self.gate.bind((self.host, self.port))  
        self.listen()

    def listen(self):
        self.gate.listen(10)
        while True:
            add = self.gate.accept()
            self.reciveFileName()
            self.reciveFile()


    def reciveFileName(self):
        while True:
            data = self.gate.recv(1024)
            self.file = data

    def reciveFile(self):
        createFile = open("new_"+self.file, "wb")
        while True:
            data = self.gate.recv(1024)
            createFile.write(data)
        createFile.close()



a = Server(1111)

Client:

class Client:
    gateway = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    #host = socket.gethostname()
    host = ''
    port = 0
    file = ''

    def __init__(self, host, port, file):
        self.port = port
        self.host = host
        self.file = file
        self.connect()

    def connect(self):
        self.gateway.connect((self.host, self.port))
        self.sendFileName()
        self.sendFile()

    def sendFileName(self):
        self.gateway.send("name:" + self.file)

    def sendFile(self):
        readByte = open(self.file, "rb")
        data = readByte.read()
        readByte.close()

        self.gateway.send(data)
        self.gateway.close()



a = Client('93.103.56.251', 1111, 'data.txt')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:09:51+00:00Added an answer on May 30, 2026 at 8:09 am

    A server has one server socket that is used to accept incoming connections, and another socket for each of these connections. From your code:

    self.gate.listen(10)
    while True:
        add = self.gate.accept()
        self.reciveFileName() # which calls self.gate.recv()
    

    Instead of operating on self.gate in reciveFilename and reciveFile (by the way, the proper spelling is receive), you should make these methods operate on the accepted connection, like this:

    def listen(self):
        self.gate.listen(10)
        while True:
            conn,address = self.gate.accept()
            self.receiveFilename(conn)
    
    def receiveFilename(self, sock):
        buf = sock.recv(1024)
        print('First bytes I got: ' + buf)
    

    Also, reciveFilename currently listens forever on the socket. Instead, you must design a proper protocol that specifies when the filename is over and the file content begins. For example, you can let the file name end with b'\0' and let the server search for that byte.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to implement a comment engine in my app (UItableView) but
I have been trying to implement HTML5 socket server to broadcast whatever it receives
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to implement the solution referenced at: Error when trying to
I have been trying to implement XOR linked list and its operations but I
I've been trying to implement unit testing and currently have some code that does
I have been trying to understand the way ActionScript's events are implemented, but I'm
I have been trying to get around this error for a day now and
I have been trying to implement a CheckBox Node Tree, where the parent nodes
I have been trying to implement hash-tables using uthash.h, following the (excellent) documentation I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.