![]() |
looking for UDP package, network programming guidance
Hey all-
A friend of mine has built this interesting (to me) bit of hardware that's intended to communicate with a PC over ethernet. The hardware has an OS written in C, and has some PC-side testing software written in Delphi, all of which I have access to. The hardware communicates with the PC via UDP. I've been working on porting the PC "test" software to Python so that 1) I understand the code, 2) don't need to go buy Delphi to help this guy out, and 3) learn enough about network programming to write the actual application interface software for off-the- shelf software to use this hardware. I spent a bunch of hours one night learning everything I needed to about wxPython to get a not-so-fancy but needs-a-lot-of-different-UI-elements test app UI running, but now the stumbling block comes up that Python doesn't seem to have any UDP handling built into its distribution. Searching the web turned up Twisted, although it seems like it might be a bit bigger than I would have hoped (in terms of, "there's a huge package here to figure out"), but as far as I can tell it's the only UDP solution out there. Is this the case? Additionally, the networking protocol is a fixed format packed bytes sort of thing; is it easy enough in Python (with Twisted) to read bytes off of the stream and then decide what to do with them? (I'm a Python newbie but somewhat of a C++ pro.) Finally, I'm also somewhat of a babe in the woods with network programming in general. Any good references for learning about this stuff, something that goes over issues of robustness, error handling strategies, and so forth? It'd be best if anything had "tutorials" written in Python, of course. ;) thanks, -tom! |
Re: looking for UDP package, network programming guidance
On Monday 07 July 2003 10:43, Gerhard Häring wrote:
> > Any good references for learning about > > this stuff, [...] > > Sorry, not that I knew of. There is a (very short) Python Socket > Programming Tutorial, but it only covers the very basics. Probably there > is some good material out there for doing socket programming in C which > you could easily map to Python, because the concepts and even the names > of the functions are pretty much the same. > W. Richard Stevens' "UNIX Network Programming" covers sockets in depth and is one of the authoritative texts on the subject. Yes, it is C. However the sockets API pretty much works the same in every language. |
Re: looking for UDP package, network programming guidance
Tom Plunket wrote:
> ...now the stumbling block comes up that Python doesn't seem to > have any UDP handling built into its distribution. Thanks a lot for the pointers, gang. Hopefully I can get something up and running in the next couple of days (or rather, the next time I have a couple of uninterrupted hours for this task), so these pointers will send me in the right direction. I definitely like the idea of a lower level solution, so this is nice. For whatever reason, my web search turned up info related only to win32all, so I assumed... :) Anyway, off to get this going. :) -tom! |
Re: looking for UDP package, network programming guidance
On Mon, 07 Jul 2003, Tom Plunket <tomas@fancy.org> wrote:
> Searching the web turned up Twisted, although it seems like it > might be a bit bigger than I would have hoped (in terms of, > "there's a huge package here to figure out"), but as far as I can > tell it's the only UDP solution out there. Is this the case? It isn't the only one, but it makes it fairly easy to write UDP servers without worrying about the irrelevant low-level details. Here is a simple example, based on an example from the UDP howto: ''' from twisted.internet import protocol, reactor class UpperEcho(protocol.DatagramProtocol): def datagramReceived(self, data, (host, port)): self.transport.write(data.upper(), (host, port)) reactor.listenUDP(9999, UpperEcho()) reactor.run() ''' Run the above in the Python interpreter, and then in a different window: moshez@green:~$ echo hello | nc -u localhost 9999 HELLO Granted, perhaps not the most efficient way to uppercase strings, but hopefully I got the idea across. Despite Twisted's "largeness", you can usually limit yourself to the howto you're interested in, and read others only as they come in useful. [If you have further Twisted questions, the Twisted mailing list is the best forum to ask in.] -- Moshe Zadka -- http://moshez.org/ Buffy: I don't like you hanging out with someone that... short. Riley: Yeah, a lot of young people nowadays are experimenting with shortness. Agile Programming Language -- http://www.python.org/ |
| All times are GMT. The time now is 01:45 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.