473,698 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

client server question


I have a simple script that runs a server where one client can connect.
I would like to make it so that many clients can connect to one server
on the same port. Where can I find how to do this?

Thanks,
--j

Aug 11 '05 #1
5 1519
John wrote:
I have a simple script that runs a server where one client can connect.
I would like to make it so that many clients can connect to one server
on the same port. Where can I find how to do this?


Start by reading http://www.catb.org/~esr/faqs/smart-questions.html to
learn how to ask better questions.

Then consider that "script that runs a server" could mean either you've
written a Python "script" that runs *as* a server, but has the
limitation of only one client connection at a time, or it could mean
that your script simply runs (via, for example, a call to os.system())
an external server program which has this limitation.

Given the ambiguity of your request, it's impossible to give a useful
answer without lots of guessing. Please clear up the above question and
provide much more detail and you'll likely get a more directly useful
response.

-Peter
Aug 11 '05 #2
import threading
import logging

############### ############### ############### ############### ##########
class Reader(threadin g.Thread):
def __init__(self, clientsock):
threading.Threa d.__init__(self )
self.logger = logging.getLogg er("Reader")

#-----------------------------------------------------------------
def run(self):
self.logger.inf o("New child %s" %
(threading.curr entThread().get Name()))
self.logger.inf o("Got connection from %s" %
(clientsock.get peername()))

############### ############### ############### ############### ########
# set up a socket to listen for incoming connections from our clients
s = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
s.setsockopt(so cket.SOL_SOCKET , socket.SO_REUSE ADDR, 1)
s.bind((host, port))
s.listen(1)

while True:
try:
clientsock, clientaddr = s.accept()
except KeyboardInterru pt:
raise
except:
traceback.print _exc()
continue

client = Reader(clientso ck)
client.setDaemo n(1)
client.start()

Aug 11 '05 #3
Thanks a lot,
I think I could modify this to get my work done.
--j

Chris Curvey wrote:
import threading
import logging

############### ############### ############### ############### ##########
class Reader(threadin g.Thread):
def __init__(self, clientsock):
threading.Threa d.__init__(self )
self.logger = logging.getLogg er("Reader")

#-----------------------------------------------------------------
def run(self):
self.logger.inf o("New child %s" %
(threading.curr entThread().get Name()))
self.logger.inf o("Got connection from %s" %
(clientsock.get peername()))

############### ############### ############### ############### ########
# set up a socket to listen for incoming connections from our clients
s = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
s.setsockopt(so cket.SOL_SOCKET , socket.SO_REUSE ADDR, 1)
s.bind((host, port))
s.listen(1)

while True:
try:
clientsock, clientaddr = s.accept()
except KeyboardInterru pt:
raise
except:
traceback.print _exc()
continue

client = Reader(clientso ck)
client.setDaemo n(1)
client.start()


Aug 15 '05 #4
John schrieb:
I have a simple script that runs a server where one client can connect.
I would like to make it so that many clients can connect to one server
on the same port. Where can I find how to do this?

Thanks,
--j


use sockets.

the socket accept mehtoh returns a new socket (so now you hava one
"server socket" and a connection between to "client sockets" one used by
the requesting client and one created at the server side (retrund from
accept) ). you should start a new thread/process with this new socket
to handle the client request and use the "old" server socket again with
the accept method to wait for the next client to connect.
Aug 15 '05 #5
Robert Wierschke wrote:
John schrieb:
I have a simple script that runs a server where one client can connect.
I would like to make it so that many clients can connect to one server
on the same port. Where can I find how to do this?

Thanks,
--j


use sockets.


Or, if you have no interest at all in the gory details and problems
of socket programming, have a look at Pyro (http://pyro.sourceforge.net).
Pyro lets you invoke remote python objects as if they were just regular
python objects.

--Irmen
Aug 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2570
by: Matt | last post by:
I think this is the basic concept in ASP server-side development. My boss told me web application is NOT client-server application. I argued with him because browser is the client, and the server code put in server. Then web application should be a client-server application. My understanding is that a web application is an application that runs on a browser. But client-server application is not necessary a web application. Please...
18
7375
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure client-side javascript. I forgot to bookmark it, and now I can't find it. Anyone?
7
3367
by: CT | last post by:
Hi, This might seem like a basic question but I have some doubts, please humour me. I have a client-server application using java where each client on each machine needs to directly communicate directly with the database. Do I need a separate db2 connect on each such machine. Please advice.
12
2990
by: ShepardBerry | last post by:
This may be a dumb question, but I'm not finding anything specifically what I'm looking for. Still kind of new to .NET as well. What I'm trying to do that I know I could do in VB6.0/ASP is to create a client side object set some properties and have it run some code. I know that in VB6/asp it was fairly straight forward by creating an ActiveX control, register it and then VBScripting the CreateObject("xxx.xxxx") command and it worked...
3
2657
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links on the subject? (and yes, I have already googled it at length, but still no strong decision) ============= After a long stint of pure-desktop / pure-server applications, I'm currently working on a number of smart-client projects in C# using...
9
2413
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that when I give a path like @"C:\holdfiles\myfile.txt" it looks on the server C drive. How do I pull from the client? Do I need a different class and/or method? Filestream? -- Thanks,
1
1339
by: Frank Millman | last post by:
Hi all I am developing a multi-user business/accounting application. It is coming along nicely :-), though rather slowly :-( I have hit an issue which will require a lot of changes to the code I have written so far, together with an increase in complexity and all the bad things that follow from that. Before I go ahead and make the changes, I thought I would bounce it off the group and see if there is a simpler approach.
2
4718
by: Wimpie van Lingen | last post by:
Hey I have some more questions with regards to Remoting in .NET 2. I'm using TCP with the Binary formatter. My solution consists of 4 projects: - Class Library containing the server classes which Inherits MarshalByRefObject (ok, at this stage it only contains one class... but its gonna grow) - Class Library containing common classes and interfaces that will be shared between all projects. This include interfaces for the server...
11
4881
by: Jeff | last post by:
Hello everyone. I've searched through the archives here, and it seems that questions similar to this one have come up in the past, but I was hoping that I could pick your Pythonic brains a bit. Here's a broad overview of what I need to do: cross-platform, client- side GUI apps that interact with a server backed by a database. I'd also like the possibility of having a web interface for small portions of the app. It will be a fairly...
6
4916
by: 7stud | last post by:
My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv textport = sys.argv s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.