-
Notifications
You must be signed in to change notification settings - Fork 7
SSQ_SERVER
Structure representing an instance of a Source game server.
#include <ssq/server.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
const char *hostname = "127.0.0.1";
uint16_t port = 27015;
time_t timeout = 10000; // ms
SSQ_SERVER server;
/* Initialization */
if (!ssq_server_init(&server, hostname, port)) {
fprintf(stderr, "ssq_server_init: %s: %s\n", hostname, ssq_server_err_msg(&server));
exit(EXIT_FAILURE);
}
/* Timeout */
ssq_server_timeout(&server, SSQ_TIMEOUT_RECV | SSQ_TIMEOUT_SEND, timeout);
// equivalent to
ssq_server_timeout(&server, SSQ_TIMEOUT_RECV, timeout);
ssq_server_timeout(&server, SSQ_TIMEOUT_SEND, timeout);
// ...
/* Cleanup */
ssq_server_cleanup(&server);-
SSQ_TIMEOUT_RECV: Sets the receive timeout. -
SSQ_TIMEOUT_SEND: Sets the send timeout.
-
SSQE_OK: Success. -
SSQE_SYSTEM: System error. -
SSQE_INVALID_RESPONSE: Invalid response. -
SSQE_UNSUPPORTED: Unsupported feature. -
SSQE_GAI: getaddrinfo error. -
SSQE_NO_SOCKET: Could not create socket.
Initialize a Source game server structure.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | SSQ_SERVER * |
no | Source game server structure to initialize. |
| hostname | const char * |
yes | Game server hostname. |
| port | uint16_t |
Game server port number. |
Returns true if the Source game server was initialized successfully, otherwise
returns false and sets the error code and message accordingly.
ssq_server_cleanup when done using it.
Free a Source game server structure.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | SSQ_SERVER * |
no | Source game server structure to free. |
Set the receive/send timeouts of a Source game server structure.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | SSQ_SERVER * |
no | Source game server structure to configure. |
| which | SSQ_TIMEOUT |
Timeouts to set (bitwise). | |
| value_in_ms | time_t |
Timeout value in milliseconds. |
Determine if the last error of a Source game server structure is set to SSQE_OK.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
no | Source game server structure to diagnose. |
Returns whether the Source game server structure has no error currently set.
💡 This is a shortcut for ssq_server_err_code(...) == SSQE_OK.
Get the last error's error code of a Source game server structure.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
no | Source game server structure to diagnose. |
Returns the last error's error code of the Source game server structure.
Get the last error's error message of a Source game server structure.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
no | Source game server structure to diagnose. |
Returns a read-only string corresponding to the last error of a Source game server structure.
Clear the last error of a Source game server structure.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
no | Source game server structure to reset. |