Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Maximum array size, C++, Linux. Tried 32 bit signed and unsigned.

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 1st Mar 2018 11:54
Hello peeps

I want to make an array to store extra information about each socket connection. So I am trying to create an array at size 32bit signed or unsigned, but that won't compile. This array will be SOCKET_CLIENTS[socket_connection_id], so it has to be able to store the maximum socket ID. What is maximum socket ID AppGameKit will create? What is the largest array I can create? I use Xubuntu x64, Netbeans, and the newest AGK2. I am having troubles setting Netbeans to C++11, so I might be using C++98 :-P I am using fixed arrays. I plan to have my server running 24/7 with no restarts (I will have to restart for maintenance of course, but other than that, I would like it to be able to just run all the time without the need for restarts for resetting socket connection ID's). The reason why I am doing it this way is so that when a client sends socket data I can use the socket ID to see what information I have stored about this client. When using the regular message system I can use SetNetworkClientUserData, but there is no similar commands for sockets, as far as I know.
13/0
Zep
22
Years of Service
User Offline
Joined: 31st Aug 2002
Location: From PA, USA. Currently reside in Hanoi, Vietnam
Posted: 1st Mar 2018 13:58
Quote: "So I am trying to create an array at size 32bit signed or unsigned, but that won't compile. "


"type": any valid type, int, string double...whatever
array name ie: foo
Elements []

Type "ArrayName"[Elements]
int foo [20]
word foo[20]
double foo[20]
string foo[20]

I think you are overthinking this....
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 1st Mar 2018 14:14
I have to store information about each connection. These connections get an ID from AppGameKit, they start at 10000 or something. The only way I can store extra information about these connections and access them again directly is by storing sockets_connections_id[SOCKET ID], otherwise, I would think I would have to do some searching through an array to find a matching socket ID. So I would like like to know what the maximum socket ID can be, and what they will rollover to when maxed out. And also, can I create an array at the size of maximum socket ID?
13/0
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 1st Mar 2018 15:42 Edited at: 1st Mar 2018 15:46
You don't need to declare an array the size of the ID returned and would almost certainly be quite wasteful if you did.

If you only want to store the ID then just


If you want to store more information than just socket ID then define a type


I wrote this on cell phone so quite likely errors but that it illustrates the idea.

Oh just realized you said C++ so just use struct instead of type, etc.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
RobbSnow
8
Years of Service
User Offline
Joined: 14th Oct 2015
Location:
Posted: 1st Mar 2018 16:57 Edited at: 1st Mar 2018 16:59
I am wondering why you are wanting to use a fixed array instead of a vector or map.
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 3rd Mar 2018 18:55
Quote: "You don't need to declare an array the size of the ID returned and would almost certainly be quite wasteful if you did."

Yes, you're right. I think I was a bit exhausted when I asked. I actually store the connection ID in a way smaller array when game hosts accept connections from players. I should just do it the same way here.
13/0

Login to post a reply

Server time is: 2024-09-30 15:33:57
Your offset time is: 2024-09-30 15:33:57