Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Learning Network Programming

Name: Anonymous 2010-05-14 11:06

Hey guys, I'm looking to learn network programming. Sockets and the IPS and so on. If possible I'd prefer a hands on sort of tutorial that teaches you how to do the actual programming, preferably in Python since that's the simplest language I know, meaning I can spend more time thinking about the new concepts involved in networking and less about the intricacies of the particular language and whatever libraries or APIs I'm using.

But really even a purely conceptual introduction to this stuff'd be nice. My current level of knowledge is nil: I know NOTHING about TCP/IP and don't even know what a socket IS. I have a cursory understanding of HTTP, but nothing more.

Name: Anonymous 2010-05-14 11:30

Name: Anonymous 2010-05-14 11:58

Name: Anonymous 2010-05-14 12:46

>>1
just lern normal networking basics.
i never programed in python, but i assume it should use the same API as pretty much any other language.

i dont know any good tutorials, but a socket is just a networking channel, somewhat like a file discriptor.

Name: Anonymous 2010-05-14 12:53

>>1
You plug a socket onto you're anus...

Wait, let's try this again.

With UDP you just send packets from some (ip)address/port pair to some other pair. The packets may get reordered or lost.

With TCP, you establish a connection from a (ip)address/port pair to some other. It provides you a reliable interface, like a pipe. Internally it uses packets too, but handles retransmission and reordering for you.

So to grab a web page via HTTP, you figure out the IP address of the server via DNS. Once you have it, you open a TCP connection/socket/whatever, from any local port, to the IP of the server on port 80 (usually). Then you just write the HTTP request, and read the response back.

You can even do this with your favorite telnet program:
$ telnet dis.4chan.org 80
Trying 204.152.204.168...
Connected to dis.4chan.org.
Escape character is '^]'.
GET /prog/ HTTP 1.1
Host: dis.4chan.org



Here the port is separated with an space, instead of ':' which is more usual. Telnet uses DNS to look up the IP address 204.152.204.168, then opens a socket to port 80. I write the request, terminated by two double lines. (This just gets writen by telnet into the socket via normal write() calls, like it was a file or a pipe). The server writes the response (not shown). Telnet read()s it and prints it to the screen. Couldn't be any simpler.

Depending on what kind of person you are it might help you to use some network sniffer such as Wireshark. Or maybe it'll confuse you more.

The socket API is the same everywhere, even on Windows, and is dead easy (search for examples, it'll be less than 50 lines of C code for something that fetches web pages). On Python I imagine it's the same thing, some kind of file-type you write to and read from.

Damn, this reads horribly, I suck at explaining things.

Name: Anonymous 2010-05-14 14:12

>>5
Do you know the difference between RFC854 and RFC2616? It's RFC1762.

Name: Anonymous 2010-05-14 14:57

>>6
Superseded by RFC1149.

Name: Anonymous 2010-11-26 9:58

Name: Anonymous 2010-11-26 11:17

Name: Anonymous 2010-12-21 12:33

Don't change these.
Name: Email:
Entire Thread Thread List