Sockets

It seems I’m having all sorts of troubles.
I have a small 2D game which has all of it’s great basics set up.
Anyways, I tried my best to look at EVERY tutorial I could find on this problem,
But nothing seems to help.
When making my game online (using sockets), I always get some sort of error.
I will find mostly a problem with:
Connections = (SOCKET*)calloc(64, sizeof(SOCKET));
and get an error like:
‘Connection’ undeclared (first use this function).
Honestly, I have no idea how to fix that.

The next problem is quite… Odd… I also have no idea how to fix:
sListen = socket(AF_INET, SOCK_STREAM, NULL);
sConnect = socket(AF_INET, SOCK_STREAM, NULL);
then I’ll get some error based upon using NULL as an int or something? (It’s not showing up anymore, but it was earlier for some strange reason)

Any ideas asto how I can create a simple socket server which will work without errors?

Thanks guys

I’m not sure this is the right place for this.
And in order to help you fix your code, we would probably need a complete, compilable piece of code from you. Something to reproduce the issue.
About the Connection issue, it just looks like you didn’t declare the variable, like this:

SOCKET* Connections = 0;

And I’m also fairly certain there is no need to manually alloc anything (except the buffers) when working with network sockets. I haven’t done it in a while but back in the days I coded a lot of abstractions for Windows/Linux sockets.
Show us the code :slight_smile: !

Anyway.

If you really are using Panda3D, then you should look into that part of the manual:
panda3d.org/manual/index.php/Networking
And use the Panda3D networking framework. I never used it but this has several advantages: it’s probably on a higher level than the WinSocket API. And it’s not limited to Windows. And it’s better to use something from a lib you already use, rather than from another lib.
If you already link your project to Panda3D, take a peak at this manual.

Without seeing actual code, my guess at your first problem is that, just as the error indicates, you’re not declaring your variables.

C++ is not like Python: you’re required to be specific about what you’re creating, and in what scope. Most relevantly to your current issue, you’re required to formally create variables, a part of which is specifying what type the variable is (C++ doesn’t allow you to change type on the fly as does Python; an integer variable doesn’t suddenly change to a float, or a string).

Have you looked at any C++ tutorials yet? This sort of thing should be covered in a decent early tutorial, I would imagine.

[edit]
shakes his fist at plaristote Ninja! NIIINJAAAA! :stuck_out_tongue: