Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > socket programming project

Reply
Thread Tools

socket programming project

 
 
drs
Guest
Posts: n/a
 
      06-26-2003
Hi,

I have a programming design question. I would like to do this in Python,
but I am not even sure about what tools are proper or where to start
reading.

I am trying to make a small network system where several client computers
connect to a server. each client can send messages to the server which must
alert all of the clients of the information in the messages. Further, the
server must be able to alert all connected clients about other occasional
information. The total number of messages is low, however. for now, security
is not an issue if that matters.

I know a way to do this in win32 using dcom, but this seems sloppy, and i
need it to run on freebsd and win32 at a minimum, and pocketPC if at all
possible. I also thought about using ZEO coupled with a Queue class, but I
am not sure about clients reacting to events in this case, or about ZODB/ZEO
on pocketPC.

(The specifics of the project are to make a wifi enabled jukebox out of an
old freebsd computer hooked to my stereo which can be controlled by all of
the other computers in the house. I did a previous version of this using
SimpleHTTPServer, but this seems a dead end for forcing the playlist queue
and such onto clients.)

Any suggestions on how to start would be appreciated.

Thanks,

doug


 
Reply With Quote
 
 
 
 
Andrew Bennetts
Guest
Posts: n/a
 
      06-26-2003
On Thu, Jun 26, 2003 at 06:02:17AM +0000, drs wrote:
> Hi,
>
> I have a programming design question. I would like to do this in Python,
> but I am not even sure about what tools are proper or where to start
> reading.


An excellent tool for socket programming is Twisted:
http://twistedmatrix.com/

> I am trying to make a small network system where several client computers
> connect to a server. each client can send messages to the server which must
> alert all of the clients of the information in the messages. Further, the
> server must be able to alert all connected clients about other occasional
> information. The total number of messages is low, however. for now, security
> is not an issue if that matters.


You might like PB, Twisted's remote object protocol, which can do all this.
It might be overkill though; I recommend you take a look at the docs and
decide for yourself. Twisted also has support for lots of standard
protocols, including stuff like XML-RPC.

If you want to use a custom protocol, that's also pretty easy in Twisted.

> I know a way to do this in win32 using dcom, but this seems sloppy, and i
> need it to run on freebsd and win32 at a minimum, and pocketPC if at all
> possible. I also thought about using ZEO coupled with a Queue class, but I
> am not sure about clients reacting to events in this case, or about ZODB/ZEO
> on pocketPC.


Twisted runs on FreeBSD and Win32, and I seem to recall someone got it
working on a PocketPC or something like it without too much effort.

> (The specifics of the project are to make a wifi enabled jukebox out of an
> old freebsd computer hooked to my stereo which can be controlled by all of
> the other computers in the house. I did a previous version of this using
> SimpleHTTPServer, but this seems a dead end for forcing the playlist queue
> and such onto clients.)


That sounds like an excellent use for Twisted. I don't think it's actively
developed, but there's a project called "mc-foo" that is a Jukebox using
Twisted. You may want to start there, rather from scratch.

-Andrew.


 
Reply With Quote
 
 
 
 
Maciej Sobczak
Guest
Posts: n/a
 
      06-26-2003
Hi,

drs wrote:

> I am trying to make a small network system where several client computers
> connect to a server. each client can send messages to the server which must
> alert all of the clients of the information in the messages. Further, the
> server must be able to alert all connected clients about other occasional
> information. The total number of messages is low, however. for now, security
> is not an issue if that matters.


You may find the YAMI project:

http://www.maciejsobczak.com/prog/yami/

to be very useful for your needs.

> i
> need it to run on freebsd and win32 at a minimum, and pocketPC if at all
> possible.


YAMI works fine on FreeBSD, Linux, MS Windows and SunOS. I did not try
it on PocketPC, but chances are it will go, if you know how to write
Makefiles for this platform.

--
Maciej Sobczak
http://www.maciejsobczak.com/

Distributed programming lib for C, C++, Python & Tcl:
http://www.maciejsobczak.com/prog/yami/

 
Reply With Quote
 
drs
Guest
Posts: n/a
 
      06-26-2003
"Irmen de Jong" <(E-Mail Removed)> wrote in message
news:3efb62a5$0$49109$(E-Mail Removed)4all.nl...

>
> If you don't care about the communication internals, (and it seems very
> likely that you don't), try Pyro : http://pyro.sourceforge.net
>
> Pyro makes it VERY easy to build distributed object systems in Python.
> (a basic client and server take no more than 5 to 10 lines of code,
> of which only two or three are Pyro-specific).
>
> If you know DCOM, you know the basics of distributed object systems,
> and you should feel at home very soon when using Pyro.
> Not forgetting that it is tremendously easier to use than DCOM..


This looks really interesting. In COM, there is the concept of a single use
server where every client shares the same instance. Python does not really
support creating a single use DCOM server, at least not last time I looked
into it. Is this something Pyro can easily do, or will I need to use a db of
some sort to keep track of shared data?

-doug


 
Reply With Quote
 
Irmen de Jong
Guest
Posts: n/a
 
      06-26-2003
drs wrote:

> This looks really interesting. In COM, there is the concept of a single use
> server where every client shares the same instance. Python does not really
> support creating a single use DCOM server, at least not last time I looked
> into it. Is this something Pyro can easily do, or will I need to use a db of
> some sort to keep track of shared data?


It actually is the default in Pyro

You're creating Pyro server object instances. Every object instance can
be referred to by a unique logical name. If your Pyro client connects to the
logical name, it will remotely access the same object instance that all
other clients that requested that object by that name also do.

So, the object's state is always shared in Pyro. This means that your
object's implementation must be able to deal with concurrent /
multithreaded invocations (although Pyro can help you a bit with this).

--Irmen de Jong

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments