C++ and MySQL for the server

Started by
13 comments, last by MisterVicodin 10 years, 12 months ago



What i mean is, what should i use to make the server? Is there a tutorial on this?

You should use tools that are available to you, and that you are comfortable in using.
Successful game servers have been written using a variety of technologies, including but not limited to C++, Java, C#, Python, Visual Basic, Erlang, JavaScript, and C.

So, the first question is: What do you already know, and what do you have available to you?


What i meant is how do i make a server? Idek how i would do any of this but no-one is even giving me a hint on how to start coding a server.

What i already know is basically how to do everything needed to make an online game except how to code a server. So any help would be great!


Google: socket tutorial. There are plenty of examples on basic client server communication out there.

You could also pick some higher level networking library (RakNet for example) and look for tutorials on that instead.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Advertisement
The FAQ for this forum has links to game network coding.

In very brief, to create a server, you can start as such:

1) Call socket() to create a TCP socket.
2) Call bind() to bind the socket to your given port, and IP address 0.0.0.0 (IPADDR_ANY).
3) Call listen() for basically historical reasons.
4) Now, enter a loop that does the following:
4.1) Put all active sockets in an FD_SET.
4.2) Call select() with that FD_SET to test readability of sockets. Perhaps use a timeout so you can run periodic events even if the server is idle.
4.3) For the listening socket, if it returns readable, it means someone is connecting; call accept() on it and allocate a data structure with incoming buffer and client information. (This is empty for now.) Put the mapping from socket ID to buffer/client information into a hash table.
4.4) For each connected socket that is readable by select(), call recv() once to attempt to fill up the incoming data buffer in the per-socket data structure. Recv() will not block the first time you call it after select() says it is readable.
4.4.1) Decode, remove, and dispatch any complete packet(s) that are in the receive buffer for this socket/client.
4.4.2) If recv() returns 0, or the client sends a "quit/disconnect" command, or the client is sending bad packets, close the socket, and de-allocate the buffer/client information structure for this socket.
4.5) Goto 4.1

That's really all there is to the basic server loop, based on select(). This will easily get you to many hundred simultaneous users.
enum Bool { True, False, FileNotFound };

The FAQ for this forum has links to game network coding.

In very brief, to create a server, you can start as such:

1) Call socket() to create a TCP socket.
2) Call bind() to bind the socket to your given port, and IP address 0.0.0.0 (IPADDR_ANY).
3) Call listen() for basically historical reasons.
4) Now, enter a loop that does the following:
4.1) Put all active sockets in an FD_SET.
4.2) Call select() with that FD_SET to test readability of sockets. Perhaps use a timeout so you can run periodic events even if the server is idle.
4.3) For the listening socket, if it returns readable, it means someone is connecting; call accept() on it and allocate a data structure with incoming buffer and client information. (This is empty for now.) Put the mapping from socket ID to buffer/client information into a hash table.
4.4) For each connected socket that is readable by select(), call recv() once to attempt to fill up the incoming data buffer in the per-socket data structure. Recv() will not block the first time you call it after select() says it is readable.
4.4.1) Decode, remove, and dispatch any complete packet(s) that are in the receive buffer for this socket/client.
4.4.2) If recv() returns 0, or the client sends a "quit/disconnect" command, or the client is sending bad packets, close the socket, and de-allocate the buffer/client information structure for this socket.
4.5) Goto 4.1

That's really all there is to the basic server loop, based on select(). This will easily get you to many hundred simultaneous users.

I did not understand any of this except how to open a socket. Can someone just add me on Skype so in case i need help i will have someone to help me out?

If you do not understand that description, then you need to first do step 0: Learn to effectively develop software. This includes being good at at least two different programming languages, and being able to read and understand the manual pages and documentation of the system libraries.
If you do not yet have those skills, you cannot develop a robust game server. Right now, you're trying to learn calculus, from a textbook written in Latin, without knowing any Latin. You need to learn the Latin before you can learn the calculus.

If you want one-on-one help, there are many contractors and consultants that will spend their time helping you out. That will cost money, though.
enum Bool { True, False, FileNotFound };

If you do not understand that description, then you need to first do step 0: Learn to effectively develop software. This includes being good at at least two different programming languages, and being able to read and understand the manual pages and documentation of the system libraries.
If you do not yet have those skills, you cannot develop a robust game server. Right now, you're trying to learn calculus, from a textbook written in Latin, without knowing any Latin. You need to learn the Latin before you can learn the calculus.

If you want one-on-one help, there are many contractors and consultants that will spend their time helping you out. That will cost money, though.

Actually, i have successfully coded many many things in about 6 or 7 other languages. And learning to effectively code has nothing to do with it. I was asking what requirements i need. Suchas the include files. I have now coded a server btw. I was simply asking for the required information needed to be able to code a server. And actually, calculus is a good suggestion but is not actually necessary. Anyways. Thanks guys for all your help. I followed a WinSock tutorial to get started and coded the rest of the server myself. Hoping that i will have my MMORPG done by December. Good day everyone.

This topic is closed to new replies.

Advertisement