Python/Java options for learning networking?

Started by
6 comments, last by Sky Warden 9 years, 10 months ago

I'd really like to learn some basic networking stuff (because, yes, some day I'd like to make some sort of multiplayer game). I know the go to standard is Beej's guide (which I've begun to read), but other than my computer architecture class last year I haven't really programmed in C at all.

I was wondering if there are any good alternative guides that utilize other languages, or if it would be best to just go with it and learn C (which I plan to learn eventually regardless). (I only mentioned Python and Java because those are the languages with which I'm currently most comfortable)

Thanks in advance.

Advertisement
Yeah, don't make games in C.

If you're going to go that route at least learn C++, C is only really useful for specialty tasks these days like writing OS level code or embedded software(because C compilers are very easy to write.) Anything game related that isn't using a higher level language will be in C++.

Beej's guide is all about basic sockets, you don't HAVE to write with those in order to get networking in a game, there are usually quite a few libraries that abstract away the details for you(C++ has Raknet for example) Java probably has a built in library and a lot of third party ones, same with Python. In fact I probably wouldn't bother dealing with sockets unless you have a good reason to(need to write your own unusual behavior or your goal is to get in depth with network coding.)

Yeah, don't make games in C.

If you're going to go that route at least learn C++, C is only really useful for specialty tasks these days like writing OS level code or embedded software(because C compilers are very easy to write.) Anything game related that isn't using a higher level language will be in C++.

Beej's guide is all about basic sockets, you don't HAVE to write with those in order to get networking in a game, there are usually quite a few libraries that abstract away the details for you(C++ has Raknet for example) Java probably has a built in library and a lot of third party ones, same with Python. In fact I probably wouldn't bother dealing with sockets unless you have a good reason to(need to write your own unusual behavior or your goal is to get in depth with network coding.)

Honestly, you can't go too much higher level than sockets and still have general-purpose network programming. You can tear a little bit of the boilerplate out, but in the end it's just an IO stream. Even specialized HTTP Clients aren't that far removed.

On the topic, python has a perfectly serviceable sockets module if you want to use it, and there are plenty of guides on the subject. I'll echo the above sentiment that C isn't a language you want to break your back over using.

Java has really good built in libraries for programming sockets [LINK] - within a few lines of code you can have a basic client - server up and running. [LINK] [LINK] .

With Python, I've personally never had any luck getting any kind of client / server running on my computer ( Windows 7, Python 2.7 ) [LINK]

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Networking is hard. There is plenty of documentation out there, but this is one of those things that you can only learn by doing.

The quintessential networking program is a chat server. While this may seem too easy to bother with, it is actually very complicated, and contains hidden inside many problems you will face creating a multiplayer game. Chat servers are easy enough to understand, just pass string messages around, and only need a very simple GUI.

But try coding one up, and you will begin asking questions like:

How does the client know where the server is?

What if I start the client before the server?

What if I try to connect two clients?

Why doesn't the server know the client is gone?

What if the server needs to restart when the clients are connected?

... and a host of other problems you really can't wrap your head around until you try it.

And read this: http://www.gamedev.net/topic/655795-your-most-valuable-debugging-techniques-for-networked-games/

for when you have problems.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Thanks to everyone for the suggestions.

I'd be more than happy to try to get a chat program running; I'll give it a shot in Java.

If you use Java, the Kryonet library makes networking a little easier.

Stay gold, Pony Boy.

There's Twisted for Python. There's also some tutorials about asynchronous programming using Twisted. I got started with this one.

This topic is closed to new replies.

Advertisement