473,395 Members | 2,253 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,395 software developers and data experts.

network programming

Hello, everyone. I just began school, and they
already assigned us science fair. Since I'm in 8th
grade, I get to do demonstrations for our projects.
I'm probably going to demonstrate Python's networking
capabilities by writing a simple instant messenger
program. I only have a few problems:

1. I know squat about Python network Programming

2. I know nothing about networks

So if any of you know of a good Python Networking
Tutorial or a website with lots of information on
networks and networking, please reply. Thanks!

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Aug 21 '05 #1
6 2362
If i had started in 8th grade, I'd be Guido MartelliPeters by now!
Anyway, these people claim to have 125 tutorials, it'll take at least a
couple hours to work thru

http://www.awaretek.com/tutorials.html

Aug 21 '05 #2
John Walton wrote:
Hello, everyone. I just began school, and they
already assigned us science fair. Since I'm in 8th
grade, I get to do demonstrations for our projects.
I'm probably going to demonstrate Python's networking
capabilities by writing a simple instant messenger
program. I only have a few problems:

1. I know squat about Python network Programming

2. I know nothing about networks

So if any of you know of a good Python Networking
Tutorial or a website with lots of information on
networks and networking, please reply. Thanks!


I believe the Twisted Matrix library has an IM module written for it and
a tutorial on programming with the library. www.twistedmatrix.com
--
--------------------------
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM: Phoenix11890
MSN: dotpyfe "@" gmail.com
IRC: lvraab
ICQ: 324767918
Yahoo: Phoenix11890
Aug 21 '05 #3
On Sun, 21 Aug 2005, John Walton wrote:
Hello, everyone. I just began school, and they already assigned us
science fair. Since I'm in 8th grade, I get to do demonstrations for
our projects. I'm probably going to demonstrate Python's networking
capabilities by writing a simple instant messenger program. I only have
a few problems:

1. I know squat about Python network Programming

2. I know nothing about networks

So if any of you know of a good Python Networking Tutorial or a website
with lots of information on networks and networking, please reply.
Thanks!


There are two sides to this problem. The first is understanding networks
in general, and the specific application protocols you're interested in.
When i say 'understanding networks in general', don't panic - i don't mean
you need to understand everything about how the internet works. In fact,
you don't really need to understand *anything* about how the internet
works, you just need to understand the interfaces it exposes to you. And,
helpfully, that interface is pretty simple: a program can get a connection
to another program, running on a different machine, which amounts ot a
pipe for bytes - both ends can write bytes to the pipe when they feel like
it, and those bytes become available for the other end to read. To open
one of these connections, you need to know the hostname or IP address of
the computer at the far end, and something called a 'port number', which
is basically a way of identifying which program on that machine you want
to talk to; if you want other programs to be able to open connections to
your program, you have to pick a port number and ask the system to give
you any connections that are made to it.

That's pretty much it for the network fundamentals. There is more -
datagram sockets, looking up IP addresses, doing funky things with sockets
- but you can forget about that until you've mastered the basics.

What you do need to understand beyond this, though, is about the
application protocol you're using. The network just gives you a way to
move streams of bytes; in order to actually do anything useful, you need
an agreement between the programs at either end of the connection about
what those bytes mean - that's an application protocol. It's basically a
file format as applied to a network connection instead of a file. Each
application protocol is completely different to every other one (well,
there are a lot of similarities, but they're mostly different), so you'll
need to read up on the one you want to use (or invent your own!) - the
documentation is (almost always) in the form of a document unhelpfully
called a Request For Comments, or RFC; the internet RFCs are published
here:

http://www.rfc-editor.org/

For example, here's the RFC for HTTP version 1.0:

http://www.rfc-editor.org/rfc/rfc1945.txt

RFCs can be pretty heavy going, but they are *the* definitive
specifications, so they're worth reading. Once you're used to them,
they're often easier to read than tutorials, i find.

The second thing is understanding how to do network programming in python.
There's a well-established API in C for network programming - the socket
API - which comes from UNIX; python uses a fairly simple translation of
this as its network API (look in the 'socket' package). The good thing
about this is that this API is well-understood and well-documented. The
bad thing is that it's a bit of a mess (compare and contrast to the API in
Java if you don't believe me). There's detailed documentation for the
socket module here:

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

And a very quick tutorial here:

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

What it comes down to, though, is that you can do:

import socket
s = socket.socket()
target = ("www.python.org", 80)
s.connect(target)
s.send("GET / HTTP/1.0\r\n\r\n")
reply = ""
while True:
line = s.recv(1000)
if (line != ""):
reply = reply + line
else:
break
s.close()

To create a connection, send some data, and then read some data. In this
case, the code sends a very simple HTTP request.

A slightly easier way to do this is using socket's makefile method - this
gives you a file-like representation of the socket, so you can read and
write data using the familiar file methods.

To accept connections from other machines, do something like this:

ss = socket.socket()
ss.bind(('', 2323))
ss.listen(5)
while True:
s, addr = ss.accept()
s.send("Hello!\r\n")
s.close()

tom

--
Eat + Read + Learn = Word
Aug 22 '05 #4
Tom Anderson wrote:
On Sun, 21 Aug 2005, John Walton wrote:

Hello, everyone. I just began school, and they already assigned us
science fair. Since I'm in 8th grade, I get to do demonstrations for
our projects. I'm probably going to demonstrate Python's networking
capabilities by writing a simple instant messenger program. I only have
a few problems:

1. I know squat about Python network Programming

2. I know nothing about networks

So if any of you know of a good Python Networking Tutorial or a website
with lots of information on networks and networking, please reply.
Thanks!

There are two sides to this problem. The first is understanding networks
in general, and the specific application protocols you're interested in.
When i say 'understanding networks in general', don't panic - i don't mean
you need to understand everything about how the internet works. In fact,
you don't really need to understand *anything* about how the internet
works, you just need to understand the interfaces it exposes to you. And,
helpfully, that interface is pretty simple: a program can get a connection
to another program, running on a different machine, which amounts ot a
pipe for bytes - both ends can write bytes to the pipe when they feel like
it, and those bytes become available for the other end to read. To open
one of these connections, you need to know the hostname or IP address of
the computer at the far end, and something called a 'port number', which
is basically a way of identifying which program on that machine you want
to talk to; if you want other programs to be able to open connections to
your program, you have to pick a port number and ask the system to give
you any connections that are made to it.

That's pretty much it for the network fundamentals. There is more -
datagram sockets, looking up IP addresses, doing funky things with sockets
- but you can forget about that until you've mastered the basics.

I tried to cover those basics as briefly as possible in the tutorial I
mentioned earlier. I'd appreciate your comments on how well I succeeded.
What you do need to understand beyond this, though, is about the
application protocol you're using. The network just gives you a way to
move streams of bytes; in order to actually do anything useful, you need
an agreement between the programs at either end of the connection about
what those bytes mean - that's an application protocol. It's basically a
file format as applied to a network connection instead of a file. Each
application protocol is completely different to every other one (well,
there are a lot of similarities, but they're mostly different), so you'll
need to read up on the one you want to use (or invent your own!) - the
documentation is (almost always) in the form of a document unhelpfully
called a Request For Comments, or RFC; the internet RFCs are published
here:

http://www.rfc-editor.org/

For example, here's the RFC for HTTP version 1.0:

http://www.rfc-editor.org/rfc/rfc1945.txt

RFCs can be pretty heavy going, but they are *the* definitive
specifications, so they're worth reading. Once you're used to them,
they're often easier to read than tutorials, i find.
Not for newbies, though very useful for ensuring high levels of
interoperability (and fascinating when you start to realize that real
products bend the RFCs in various ways).
The second thing is understanding how to do network programming in python.
There's a well-established API in C for network programming - the socket
API - which comes from UNIX; python uses a fairly simple translation of
this as its network API (look in the 'socket' package). The good thing
about this is that this API is well-understood and well-documented. The
bad thing is that it's a bit of a mess (compare and contrast to the API in
Java if you don't believe me). There's detailed documentation for the
socket module here:

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

[...]

But then Java's a bit of a mess as a language when compared with Python,
I should say. While I know the language has many adherents, it also
seems to have many programmers who only know enough to follow recipes.
This latter feature is a symptom of the language's popularity, so I
suppose we should expect the same problems in about twenty years when
Python becomes more popular than Java.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Aug 22 '05 #5
John Walton wrote:
Hello, everyone. I just began school, and they
already assigned us science fair. Since I'm in 8th
grade, I get to do demonstrations for our projects.
I'm probably going to demonstrate Python's networking
capabilities by writing a simple instant messenger
program. I only have a few problems:

1. I know squat about Python network Programming

2. I know nothing about networks

So if any of you know of a good Python Networking
Tutorial or a website with lots of information on
networks and networking, please reply. Thanks!


Is it the purpose of your project to delve into the
gory details of network programming (or sockets)?
If not, it might be extremely helpful to just not
tire yourself with endless technical debugging sessions,
and instead opt for the use of a high-level communication
mechanism like XML-RPC or Pyro...

--Irmen
Aug 22 '05 #6
On Mon, 22 Aug 2005, Steve Holden wrote:
Tom Anderson wrote:
On Sun, 21 Aug 2005, John Walton wrote:
Hello, everyone. I just began school, and they already assigned us
science fair. Since I'm in 8th grade, I get to do demonstrations for our
projects. I'm probably going to demonstrate Python's networking
capabilities by writing a simple instant messenger program. I only have a
few problems:

1. I know squat about Python network Programming

2. I know nothing about networks

So if any of you know of a good Python Networking Tutorial or a website
with lots of information on networks and networking, please reply. Thanks!
[snipzilla!]

That's pretty much it for the network fundamentals. - but you can
forget about that until you've mastered the basics.


I tried to cover those basics as briefly as possible in the tutorial I
mentioned earlier.


Oops! I missed that.
I'd appreciate your comments on how well I succeeded.
Comment #1: it's a combination of PDF and powerpoint! :) I intended to
have a look at it, but i was in a but of a rush this morning, so i'm
afraid i skipped over it. Right now, i'm using a computer that isn't
capable of reading either format; i'll have a look at the tutorial this
evening (i hope) and get back to you. Not that my opinion is worth much.

Okay, read it. Yes, that covers what we're talking about.
RFCs can be pretty heavy going, but they are *the* definitive
specifications, so they're worth reading. Once you're used to them, they're
often easier to read than tutorials, i find.


Not for newbies, though very useful for ensuring high levels of
interoperability (and fascinating when you start to realize that real
products bend the RFCs in various ways).


Maybe i'm unusual, but i've *always* preferred specs to tutorials for most
learning - specs are definitive, comprehensive and precise, whereas
tutorials are often erroneous, patchy and waffly. Yes, they take more
effort to read, but in the case of the RFCs, not that much, once you have
a very basic level of knowledge - most RFCs are very clearly written.
Perhaps the OP would be better off with tutorials, though - particularly
for the programming side rather than the actual protocols.
The second thing is understanding how to do network programming in python.
There's a well-established API in C for network programming - the socket
API - which comes from UNIX; python uses a fairly simple translation of
this as its network API (look in the 'socket' package). The good thing
about this is that this API is well-understood and well-documented. The bad
thing is that it's a bit of a mess (compare and contrast to the API in Java
if you don't believe me). There's detailed documentation for the socket
module here:

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

[...]

But then Java's a bit of a mess as a language when compared with Python,
I should say.


Oh, absolutely - but the socket API is a rare breath of simplicity.
While I know the language has many adherents, it also seems to have many
programmers who only know enough to follow recipes.
True, but let's save that rant for another day.
This latter feature is a symptom of the language's popularity, so I
suppose we should expect the same problems in about twenty years when
Python becomes more popular than Java.


I know. I left comp.lang.java.programmer because it got overrun with
clueless muppets. I don't have anything against newbies, but when a place
is crawling with them to that extent, it's not fun. clp will be like that
one day. i haven't decided if i'll take up Smalltalk or LISP next ...

tom

--
In Milan, [traffic lights] are instructions, in Rome suggestions, and in Naples Christmas decorations. -- James Dowden
Aug 22 '05 #7

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

Similar topics

8
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork =...
1
by: mch2k2 | last post by:
Hello All I have just started working on Pyhton. I need urgent help regarding Python Network Programming. I want the elctronic version of the Book: Foundations of Python Network programming by...
3
by: Jay | last post by:
Hi, I implemeneted an FTP client and server long time back using Java. I found sockets porgramming in java quite useful and easy to handle. I now wanted to implement a similar program using C++....
2
by: Jesse Engle | last post by:
i'm learning how to do some basic low-level network programming. the site i'm reading talks about "network byte order" and "host byte order". the thing is, it doesn't give an explanation as to what...
4
by: Wayne M J | last post by:
I have "Professional .Net Network Programming" and "Network Programming for MS Windows 2nd Ed", but I find both of these to be lacking in what I am looking for. Has there been any books printed...
5
by: Terry | last post by:
Could someone please suggest me a good book to learn network programming. I have been programming in C#/VB.NET/VB 6.0 and have also used a bit of C++ (not MFC/ATL/COM) I am a total novice when...
6
by: Eric | last post by:
Does anyone know of any GOOD network programming book(s) that are C# based, as well as any online tutorials and forums on network programming? Thanks
2
by: ppuniversal | last post by:
Hello, Can someone tell a good Tutorial on Network Programming in C++, except Beej's Guide and Vijay Mukhi's tutorials. I want to make a Client Server application in C++ which will involve...
9
by: Mex | last post by:
Hi, I'm looking for a good book for beginners about Network Programming. Besides Stevens' book, I would like something specific for C++ language. Any suggestions? Thanks in advantage, Massimo
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.