hi, the following sample (from docs.python.org) is a server that can
actually serve only single client at a time.
In my case I need a simple server that can serve more than one client.
I couldn't find an example on how to do that and be glad to get a
hint.
Thanks in advance
import socket
HOST = '127.0.0.1' # Symbolic name meaning the local host
PORT = 50007 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data:
break
conn.send(data)
conn.close() 5 25645
On Nov 7, 1:54 pm, Tzury Bar Yochay <Afro.Syst...@gmail.comwrote:
hi, the following sample (from docs.python.org) is a server that can
actually serve only single client at a time.
In my case I need a simple server that can serve more than one client.
I couldn't find an example on how to do that and be glad to get a
hint.
Thanks in advance
import socket
HOST = '127.0.0.1' # Symbolic name meaning the local host
PORT = 50007 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data:
break
conn.send(data)
conn.close()
POE
On Nov 7, 2007, at 12:54 PM, Tzury Bar Yochay wrote:
hi, the following sample (from docs.python.org) is a server that can
actually serve only single client at a time.
In my case I need a simple server that can serve more than one client.
I couldn't find an example on how to do that and be glad to get a
hint.
Thanks in advance
That's when it stops being simple. You'll need to spawn threads or
fork off separate processes to do that.
Erik Jones
Software Developer | Emma® er**@myemma.com
800.595.4401 or 615.292.5888
615.292.0777 (fax)
Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com
On Wed, 07 Nov 2007 13:42:18 -0600, Erik Jones wrote:
On Nov 7, 2007, at 12:54 PM, Tzury Bar Yochay wrote:
>hi, the following sample (from docs.python.org) is a server that can actually serve only single client at a time.
In my case I need a simple server that can serve more than one client. I couldn't find an example on how to do that and be glad to get a hint.
Thanks in advance
That's when it stops being simple. You'll need to spawn threads or fork
off separate processes to do that.
I think the authors of Twisted would be very surprised to find out that
their framework can only serve one client at a time.
:)
Carl Banks
Even simpler, use Twisted:
I am afraid Twisted is not the right choice in my case. I am looking
for smaller, simpler and minimal server sample.
here is its:
# a simple tcp server
import SocketServer
class EchoRequestHandler(SocketServer.BaseRequestHandler ):
def setup(self):
print self.client_address, 'connected!'
self.request.send('hi ' + str(self.client_address) + '\n')
def handle(self):
while 1:
data = self.request.recv(1024)
self.request.send(data)
if data.strip() == 'bye':
return
def finish(self):
print self.client_address, 'disconnected!'
self.request.send('bye ' + str(self.client_address) + '\n')
#server host is a tuple ('host', port)
server = SocketServer.ThreadingTCPServer(('', 50008),
EchoRequestHandler)
server.serve_forever() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MBW |
last post by:
The following code is for a simple server/client asplication that
allows the user to toggle between serve and or client modes and
send/recieve a message however i am getting an Attribute error on...
|
by: Eric Law |
last post by:
I want to create a simple applicaiton similar to the MSDN viewer with the tree view on the left and diplay html page on the right depends on the tree selection. any idea where I can get a sample of...
|
by: Mihajlo Cvetanovic |
last post by:
Hello,
I would like to change the behavior of msgina like this:
- There is no way to login without the smart card.
- Upon insert of smart card my dialog appears, user inserts the data,
mygina...
|
by: |
last post by:
I'm new to VS.NET, C#, and the enumerated datatype. I'm told that VS.NET
2005 Intellisense will pop up the members of an enum as a selection list if
you are using the enum as a method parameter....
|
by: Link |
last post by:
hello i want to make simple server client system that send data
like that one :
http://www.eggheadcafe.com/articles/20020323.asp
just no console app
well i want to make form with 2...
|
by: zenBen |
last post by:
Hello,
I have a C++ program that outputs about 1MB of simple text to a local csv file. I now want to distribute the program, have people download and use it, then have the program stream that...
|
by: sathish.sarod |
last post by:
Does Any one have a SQL server sample database atleast with 50 mb of
data or can anyone give me a link with I could download it?
Regards
Sathish S N
|
by: boazin |
last post by:
Hi all,
I was trying to build a rather simple server (with a twist) using
asyncore and got myself complicated.
Well, here's the deal:
My server will handle multiple connections, some require...
|
by: Joe |
last post by:
Every thing I have fount was for C Sharp 2005, and I can't get any thing
to work. Can some some show me a code for a telnet server in C Sharp
2008 that will a allow more then one connection.
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |