[Tutor] sockets, servers, clients, broadcasts...?

Alex Hall mehgcap at gmail.com
Fri Jun 4 00:03:34 CEST 2010


Hi all,
I am a CS major, so I have had the required networking class. I get
the principles of networking, sockets, and packets, but I have never
had to actually implement any such principles in any program. Now I
have this Battleship game (not a school assignment, just a summer
project) that I am trying to make playable over the internet, since I
have not written the AI and playing Battleship against oneself is
rather boring.

Right now I am just trying to figure out how to implement something
like the following:
*you start the program and select "online game"
*you select "server" or "client" (say you choose "server")
*somehow, your instance of the program starts up a server that
broadcasts something; your enemy has selected "client", and is now
(SOMEHOW) listening for the signal your server is broadcasting
*the signal is picked up, and, SOMEHOW, you and your opponent connect
and can start sending and receiving data.

First, how does the client know where to look for the server? I am not
above popping up the server's ip and making the client type it in, but
a better solution would be great.
How do I make it so that the client can find the server correctly? The
above IP is one thing, but are ports important here? Not a big deal if
they are, but I am not sure. Does someone have an example of this
process?

Thanks. I know I have emailed this list (and other lists) before about
this, but my peer-to-peer has not even started to look promising yet,
since this is my first time ever doing anything remotely like this
from a programming perspective, in any language. For now, it is all a
frustrating and confusing tangle of Socket objects and low-level
calls, but hopefully things will start to clear up over the next few
days.

-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap


More information about the Tutor mailing list