Socket Programming

K

Kamuela Franco

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

trainee
 
E

Erik Max Francis

Kamuela said:
Can someone give me some general information on socket programming in
Python.

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

Bjorn Pettersen

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
 
M

Michael Geary

Benjamin said:

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
 
T

trainee

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?
 
E

Erik Max Francis

trainee said:
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.
 
M

Michael Geary

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
 
B

Bjorn Pettersen

[posted and mailed]

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
 
A

Alex Martelli

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
 
R

Rene Pijlman

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.
 
A

Alex Martelli

Rene said:
Alex Martelli:

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

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
 
P

Peter Hansen

trainee said:
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?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top