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

  • Home
  • SEARCH
  • 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 8552091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:20:41+00:00 2026-06-11T14:20:41+00:00

I am currently working on a server in Python, the problem I am facing

  • 0

I am currently working on a server in Python, the problem I am facing is the client could not retrieve the sent data from server.

The code of the server is:

import sys
import socket
from threading import Thread

allClients=[]

class Client(Thread):

    def __init__(self,clientSocket):
                Thread.__init__(self)
                self.sockfd = clientSocket #socket client
                self.name = ""
                self.nickName = ""

    def newClientConnect(self):

      allClients.append(self.sockfd)
      while True:
            while True:
                try:
                    rm= self.sockfd.recv(1024)
                    print rm

                    try:
                        self.sockfd.sendall("\n Test text to check send.")
                        print "Data send successfull"
                        break


                    except socket.error, e:
                        print "Could not send data"

                    break

                except ValueError:
                       self.sockfd.send("\n Could not connect properly")


    def run(self):
                self.newClientConnect()
                self.sockfd.close() 
                while True:
                        buff = self.sockfd.recv(1024)

                        if buff.strip() == 'quit':
                            self.sockfd.close()
                            break # Exit when break
                        else:
                            self.sendAll(buff)
#Main
if __name__ == "__main__":

    #Server Connection to socket:
    IP = '127.0.0.1'
    PORT = 80
    serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serversocket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR,1)

    print ("Server Started")
    try:
        serversocket.bind(('',5000))
    except ValueError,e:
        print e
    serversocket.listen(5)

while True:
        (clientSocket, address) = serversocket.accept()
        print 'New connection from ', address
        ct = Client(clientSocket)
        ct.start()

__all__ = ['allClients','Client']

#-- 

And the client connecting is:

import socket

HOST = '192.168.1.4'    # The remote host
PORT = 5000              # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

data = s.recv(1024)
s.close()
print 'Received', data#repr(data)

In need of a quick solution….
Thanks,

  • 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-06-11T14:20:42+00:00Added an answer on June 11, 2026 at 2:20 pm

    I tested out your code, and when I commented out

    rm= self.sockfd.recv(1024)
    print rm
    

    it worked fine. Basically the server stopped there to wait for a message that never came. If it still does not work for you, there might be two problems. Either you have a firewall that blocks the connection somehow, or you have old servers running in the background from previous tries that actually wasn’t killed. Check your processes if pythonw.exe or equivalent is running when it shouldn’t be, and kill it.

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

Sidebar

Related Questions

I'm currently working on a python project, that requires file transmission from a client
I am currently working on a python script that pulls data from a table
I am currently working on a web-app/server in python and cherrypy. Right now, I
I'm currently working on a client/server based Java-program for a customer. I googled a
I'm currently working on migrating an application from MS-Access to MS SQL Server. In
Currently, I'm working on a project where I have a server - client relationship
I'm currently working on an emulation server for a flash-client based game, which has
I am currently working on exposing data from legacy system over the web. I
Currently I am working on a project which use python as server side script
I'm currently working on several custom ASPX server controls. Of course these controls do

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.