473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Simple UDP server

I am looking for the right way to write a small and simple UDP server.

I am wondering between Forking, Threading (found at SocketServer.py)
and the one describes at the snippet below.

Can you tell me the advantages and disadvantages of each
Would the one below will be capable of holding 30 concurrent
connections?

I have no intention of using Twisted or alike since I am looking for
making it as lightweight as possible

Thanks in advance,
Tzury Bar Yochay

# begin of snippet

from socket import *
# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(('',50008))

while 1:
data,addr = UDPSock.recvfrom(4*1024)

if not data:
print "No data."
break
else:
print 'from:', addr, ' data:', data
UDPSock.close()
Sep 10 '08 #1
4 2011
Tzury Bar Yochay wrote:
Would the one below will be capable of holding 30 concurrent
connections?
UDP is a connectionless datagram protocol, so that question doesn't
really make much sense.

</F>

Sep 10 '08 #2
On Sep 10, 9:55*pm, Fredrik Lundh <fred...@pythonware.comwrote:
Tzury Bar Yochay wrote:
Would the one below will be capable of holding 30 concurrent
connections?

UDP is a connectionless datagram protocol, so that question doesn't
really make much sense.
So what if it is connectionless.
It would make sense if you get a load of users who sends large sets of
binary data to each other.
Sep 10 '08 #3
Tzury Bar Yochay <Af**********@gmail.comwrote:
I am looking for the right way to write a small and simple UDP server.

I am wondering between Forking, Threading (found at SocketServer.py)
and the one describes at the snippet below.

Can you tell me the advantages and disadvantages of each
Would the one below will be capable of holding 30 concurrent
connections?

I have no intention of using Twisted or alike since I am looking for
making it as lightweight as possible
For UDP I wouldn't thread or, fork, I'd use select and run
asynchronously.

http://docs.python.org/lib/module-select.html

Actually if I really had to do this I'd use twisted. Right tool for
the job!

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Sep 11 '08 #4
On Thu, Sep 11, 2008 at 10:36 AM, Nick Craig-Wood <ni**@craig-wood.comwrote:
For UDP I wouldn't thread or, fork, I'd use select and run
asynchronously.

http://docs.python.org/lib/module-select.html

Actually if I really had to do this I'd use twisted. Right tool for
the job!
For anyone interested, pymills is an
event-driven, asynchronous library
geared towards Component architectures.

It currently uses select for it's socket
components, TCPServer, TCPClient,
and it's UDP counter-parts.

cheers
James

--
--
-- "Problems are solved by method"
Sep 11 '08 #5

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

Similar topics

1
by: Thomas | last post by:
Hi, Sorry for the stupid subject, but here it goes: I need a simple Webserver which can 1. serve xmlrpc-methods 2. send multicast packets on local network to get response from a similar...
3
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...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
2
by: Vitali Gontsharuk | last post by:
Hi! I have a problem programming a simple client-server game, which is called pingpong ;-) The final program will first be started as a server (nr. 2) and then as a client. The client then...
0
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...
4
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a...
2
by: Eric | last post by:
Simple problem - binding Visible property of label to Checked property of radiobutton on the same form. How do I do that in VS2005?? Visible="<%# radiob.Checked %>" - DOESN'T WORK It was so...
1
by: Ted | last post by:
In MS SQL I used the following to create a stored procedure. USE AdventureWorks; GO IF OBJECT_ID ( 'HumanResources.usp_My_Search', 'P' ) IS NOT NULL DROP PROCEDURE HumanResources.usp_My_Search;...
4
by: RN1 | last post by:
An ASPX page, named LinkButton.aspx, has a single LinkButton & nothing else. The code is very simple: <form runat="server"> <asp:LinkButton ID="lnk" PostBackUrl="Page1.aspx" Text="CLICK"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
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...
1
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)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.