Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Socket Programming

4 views
Skip to first unread message

Kamuela Franco

unread,
Dec 25, 2003, 5:46:02 AM12/25/03
to
Can someone give me some general information on socket programming in
Python.

trainee


Erik Max Francis

unread,
Dec 25, 2003, 6:00:47 AM12/25/03
to
Kamuela Franco wrote:

> Can someone give me some general information on socket programming in
> Python.

Very much like socket programming in C, only much easier :-).

--
__ Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ There are countless planets, like many island Earths ...
-- Konstantin Tsiolkovsky

Kamuela Franco

unread,
Dec 25, 2003, 6:01:37 AM12/25/03
to
Sounds quite fun then. Now onto tutorials, got any?

Kamuela Franco


Bjorn Pettersen

unread,
Dec 25, 2003, 6:09:04 AM12/25/03
to
"Kamuela Franco" <kamu...@verizon.net> wrote in news:KdzGb.23400$NZ1.18286
@nwrddc02.gnilink.net:

> Can someone give me some general information on socket programming in
> Python.
>
> trainee

There's nothing special about socket programming in Python, any book on the
subject will do (or just the Python docs, if you've done socket programming
elsewhere).

If you have specific issues, feel free to ask them (provide code for what
you've tried if possible)... and if you give a hint about your experience
level with sockets it would potentially prevent someone from writing the
first chapters of a new book, and also be more useful to yourself <wink>.

-- bjorn

A.M. Kuchling

unread,
Dec 25, 2003, 11:15:02 AM12/25/03
to
On Thu, 25 Dec 2003 11:01:37 GMT,
Kamuela Franco <kamu...@verizon.net> wrote:
> Sounds quite fun then. Now onto tutorials, got any?

Gordon McMillan's tutorial at http://www.amk.ca/python/howto/sockets/ may be
helpful.

--amk

Benjamin Han

unread,
Dec 25, 2003, 1:07:49 PM12/25/03
to

Michael Geary

unread,
Dec 25, 2003, 2:21:34 PM12/25/03
to
> Kamuela Franco wrote:
> > Can someone give me some general information on socket
> > programming in Python.

Benjamin Han wrote:
> http://www.amk.ca/python/howto/sockets/sockets.html

That's a great introduction to sockets. I'd like to add one other thing:
Kamuela, do you know if you need to use sockets for what you're doing, or is
there possibly some higher-level module in Python that can help you out?
Take a look here:

http://www.python.org/doc/current/lib/internet.html

If none of those modules do what you need and you do need to write your own
socket code, the source code for those modules (in the Lib directory of your
Python installation) will give you good examples of working socket code.

-Mike


trainee

unread,
Dec 25, 2003, 7:17:05 PM12/25/03
to
Thanks, everyone.
Michael: I am really just fooling around for the moment. Are you telling me
that there are modules for specific things like IRC?


trainee

unread,
Dec 25, 2003, 7:17:54 PM12/25/03
to
Do you think you could recommend a book on Python that includes sockets?


Erik Max Francis

unread,
Dec 25, 2003, 11:28:43 PM12/25/03
to
trainee wrote:

> Michael: I am really just fooling around for the moment. Are you
> telling me
> that there are modules for specific things like IRC?

Indeed there are. Search for irclib.

--
__ Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE

\__/ I'm sharing the joy / I'm glowing like sunshine
-- Chante Moore

Michael Geary

unread,
Dec 26, 2003, 12:54:14 AM12/26/03
to
> Michael: I am really just fooling around for the moment. Are you
> telling me that there are modules for specific things like IRC?

There's no IRC module in the standard distribution, although there are
modules for several other protocols listed in the page I referenced earlier.

But seek and ye shall find:

http://www.google.com/search?q=python+irc

A good rule of thumb with Python is to look for some existing code before
writing your own. There's a good chance someone has written it already!

-Mike


Michel Claveau/Hamster

unread,
Dec 26, 2003, 2:52:01 AM12/26/03
to
Good.


Bjorn Pettersen

unread,
Dec 26, 2003, 5:13:44 AM12/26/03
to
[posted and mailed]

"trainee" <kamu...@verizon.net> wrote in news:S6LGb.5854$UB3.2232
@nwrddc03.gnilink.net:

> Do you think you could recommend a book on Python that includes sockets?

Starting on the web first (it's free :-) the socket howto is probably your
best bet:

http://www.amk.ca/python/howto/sockets/

You can also look at asynchronous sockets at:

http://squirl.nightmare.com/medusa/async_sockets.html

When it comes to books, most of them seem to have decent chapters on it. I
like "(the eff-bot guide to) The Standard Python Library", but my copy is
severely dated :-) I think he finally published it as a "real" book, but I
haven't seen a recent copy...

"Python Programming on Win32" has a short section on sockets that might be
enough, and if you're going to work on win32 systems I'd definitely
recommend it.

The Python Cookbook has a couple of receipes on sockets (and everything
else ;-) You can get the receipes on the web at
http://aspn.activestate.com/ASPN/Python/Cookbook/

Finally, I'd be very surprised if "Python in a Nutshell" by Alex Martelli
didn't have the best coverage of them all, however that book is still on my
list so I'll have to let someone else comment on it...

-- bjorn

Alex Martelli

unread,
Dec 26, 2003, 9:00:11 AM12/26/03
to
Bjorn Pettersen wrote:
...

> Finally, I'd be very surprised if "Python in a Nutshell" by Alex Martelli
> didn't have the best coverage of them all, however that book is still on
> my list so I'll have to let someone else comment on it...

I'm obviously biased, so I won't comment, but the Nutshell does indeed
have a full chapter devoted to sockets and server-side modules.

Fortunately, you need not rely on others' opinions about it: you can
visit safari.oreilly.com and join, for free, for two weeks, to read one
or more chapter from the Nutshell (and/or many other books) online. Just
remember to cancel the subscription within 2 weeks so you won't have
to pay for it!


Alex

Rene Pijlman

unread,
Dec 26, 2003, 9:19:32 AM12/26/03
to
Alex Martelli:
>visit safari.oreilly.com
>Just remember to cancel the subscription within 2 weeks so you won't have
>to pay for it!

What's wrong with paying for all that good stuff.

--
René Pijlman

Alex Martelli

unread,
Dec 26, 2003, 11:33:51 AM12/26/03
to
Rene Pijlman wrote:

Sorry, I generally conclude the above advice with "unless of course you
find the safari service useful" but I was a bit rushed this time.

I do, personally, find safari quite useful and worthwhile (and how!),
but since, here, I was suggesting using it just as a way to evaluate
books (the paper kind...) to decide whether you want to buy them, it
might not be worth enough (if used only in that capacity) to pay for.
Of course, such judgments are inherently subjective.


Alex

Peter Hansen

unread,
Jan 5, 2004, 5:38:51 PM1/5/04
to

In addition to the other responses to this: the Twisted package does include
IRC support, along with dozens of other protocols and both higher and lower
level things galore, generally or at least often done in a way that vastly
simplifies the whole issue well beyond what other approaches have managed.
Go to www.twistedmatrix.com to learn more.

-Peter

0 new messages