Ok, now I am getting really lost with all the different things with client-server architecture. I know the basics and stuff but I was originally going to use ODBC to have my C++ program connect to my SQL server but than I started reading about sockets and winsock and I am not quite sure how they fit into it all. I mean if you have a server in C++ and a client in C++ and they create their sockets on a UDP connection, how does the client request data and different things from another C++ program, I mean its not like you can just go and use an SQL query. Is there a query language for winsock or am I on the wrong path here. I think I got screwed up between two different things. Basically I need to know how can a C++ program query for data to another C++ program, besides the connection details, like how does it get specific data if you know what I mean.

winsock is just the windows API to the sockets transport layer.
Like the envelope you use for traditional mail has nothing to do with the letter you write, which is inside the envelope.

As for the client/server bit, the query "language" can be anything you like, so long as both ends agree on what it means.
Eg.
"send me record 1 of file 2"
"send me all records where field 1 is 42"

- Parse the request
- Evaluate it
- Collect results
- Send 'em back to the client.

ok, but how do you make up your own query language like that. So that both ends know what it means since it is not an sql query. Also do you have to have winsock in a C++ networked program for windows?

so what should I use if I am implementing a 2D MMORPG client-server system

-SQL Database with ODBC connection from client
OR
-Winsock to establish connection between a client program and a server program.

I've no idea, what kind of database does your MMORPG have?

> SQL Database with ODBC connection from client
> Winsock to establish connection between a client program and a server program.
They're the same thing, with a different level of abstraction.

Client
- send request to server

Server
- receive request
- generate response
- send response

Client
- get response

Rinse and repeat.

I imaging for your game, things like "get player stats" and "update stats" might be two kinds of request.

Now you can do this at a low level with just C++ code you roll your own, or you design a database schema to represent all the objects in your game.
With a database, you might have say an object table, an NPC table, a players table etc.

I have an sql database with all sorts of data in each table, such as characters,creatures,items,locations

so If I just used C++ code would that just be pure winsock connections between the server and the client.

and how would my sql database fit into that?

also what are the standard queries with winsock for retreiving variables that the server has in memory or is their a book or soemthing with that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.