-
Notifications
You must be signed in to change notification settings - Fork 7
SSQ_SERVER
Source server instance responsible for storing networking and error information.
#include <ssq/server.h>
/* Initialization */
SSQ_SERVER *server = ssq_server_new("127.0.0.1", 27015);
/* Error handling */
if (server == NULL) {
fprintf(stderr, "ssq_server_new: memory exhausted\n");
exit(EXIT_FAILURE);
}
if (!ssq_server_eok(server)) {
fprintf(stderr, "ssq_server_new: %s\n", ssq_server_emsg(server));
ssq_server_free(server);
exit(EXIT_FAILURE);
}
/* Configuration */
ssq_server_timeout(&server, SSQ_TIMEOUT_RECV | SSQ_TIMEOUT_SEND, 2500); // ms
// equivalent to
ssq_server_timeout(&server, SSQ_TIMEOUT_RECV, 2500); // ms
ssq_server_timeout(&server, SSQ_TIMEOUT_SEND, 2500); // ms
/* Cleanup */
ssq_server_free(server);| Name | Description |
|---|---|
SSQ_TIMEOUT_RECV |
Selects the SO_RCVTIMEO timeout |
SSQ_TIMEOUT_SEND |
Selects the SO_SNDTIMEO timeout |
| Name | Description |
|---|---|
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 an endpoint for communication |
Allocates a new Source server instance.
| Name | Type | Nullable | Description |
|---|---|---|---|
| hostname | const char * |
✅ | Source server hostname. |
| port | uint16_t |
Source server port number. |
Returns a new Source server instance which must be freed using ssq_server_free.
NULL.
Frees a Source server instance returned by ssq_server_new.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | SSQ_SERVER * |
✅ | Source server instance to free. |
Sets the SO_RCVTIMEO and SO_SNDTIMEO timeouts of a Source server instance.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | SSQ_SERVER * |
❌ | Source server instance to configure. |
| which | SSQ_TIMEOUT_SELECTOR |
Timeouts to set (bitwise flags). | |
| value_in_ms | time_t |
Timeout value in milliseconds. |
Determines if the last error of a Source server instance is set to SSQE_OK.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
❌ | Source server instance to diagnose. |
Returns whether the Source server instance has no error currently set.
💡 This is a shortcut for ssq_server_ecode(...) == SSQE_OK.
Gets the last error code of a Source server instance.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
❌ | Source server instance to diagnose. |
Returns the last error code of the Source server instance.
Gets the last error message of a Source server.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
❌ | Source server instance to diagnose. |
Returns the last error message of the Source server instance.
Clears the last error of a Source server.
| Name | Type | Nullable | Description |
|---|---|---|---|
| server | const SSQ_SERVER * |
❌ | Source server instance to clear. |