Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Programming with Internet  (Read 612 times)

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Programming with Internet
« on: August 10, 2013, 03:32:19 am »

I've been trying to understand how network applications work, but every tutorial and lesson I've looked up has been unhelpful at best. The ones I've read explain how to use Python's socket module, but they don't offer any actual understanding of what a socket or a host or a port actually is. Even if it's as simple as the "mailbox" analogy commonly used to describe variables, I could really use some help understanding the concepts behind networking.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Aptus

  • Bay Watcher
  • Indeed ôo
    • View Profile
Re: Programming with Internet
« Reply #1 on: August 10, 2013, 04:53:54 am »

I am going to do the same thing I did in an earlier thread about networking and recommend a book. Specifically 'Computer Networking: A Top-down Approach' by James Kurose and Keith Ross. (ISBN: 9780273768968).

The book goes over all the basics you need to understand networks and has some very good programming examples for things like streaming media, peer to peer networking etc. It is also very well written and structured, I had it as a course book in uni and it is probably the first of those I've had where I actually sat down and read the whole thing cover to cover without groaning.

It does not only bring up programming though, it does that, but it also gives you the "big picture" so if you are only interested in the programming part there might be more targeted literature but from your post it seems like you need to understand actual networks, protocols and terminology first :)
Logged

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Programming with Internet
« Reply #2 on: August 15, 2013, 07:54:32 am »

First some terms:

Host: a computer on the network, usually identified by its IP address (4 numbers separated by periods "192.168.12.97" or such) or hostname ("google.com").

Port: If a host is a hotel, the port is the room number. It's a more-or-less arbitrary meeting point where network programs can communicate without interfering with other programs. There are a large number of ports already in common use by existing software, and numbers below 1024 may be reserved by the OS. See also: Wikipedia

Socket: a potentially open connection to a specific host and port

How do you make use of a socket in a program?

I've not used Python, but the calls for reading and writing to a socket are usually similar to those used for file I/O. Of course there are differences: with a file there's usually always either more data or EOF; sockets may be open but still not have any data to read (because the remote machine hasn't sent any).


Hope this helps. Network programming can be both the most fun, and most frustrating, part of a project.
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Tellemurius

  • Bay Watcher
  • Positively insane Tech Thaumaturgist
    • View Profile
Re: Programming with Internet
« Reply #3 on: August 15, 2013, 05:26:53 pm »

two things to know: TCP and UDP protocol, that is all.