Sign in to follow this  
Cameron Basham

Python/Java options for learning networking?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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]

Edited by Shippou

Share this post


Link to post
Share on other sites

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.

Edited by Glass_Knife

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this