1#ifndef KORE_NETWORK_SOCKET_HEADER
2#define KORE_NETWORK_SOCKET_HEADER
14typedef enum kore_socket_protocol { KORE_SOCKET_PROTOCOL_UDP, KORE_SOCKET_PROTOCOL_TCP } kore_socket_protocol;
16typedef enum kore_socket_family { KORE_SOCKET_FAMILY_IP4, KORE_SOCKET_FAMILY_IP6 } kore_socket_family;
20typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
25typedef _W64
unsigned int UINT_PTR, *PUINT_PTR;
27typedef UINT_PTR SOCKET;
38 kore_socket_protocol protocol;
39 kore_socket_family family;
74KORE_FUNC
bool kore_socket_set(
kore_socket *socket,
const char *host,
int port, kore_socket_family family, kore_socket_protocol protocol);
103KORE_FUNC
bool kore_socket_bind(
kore_socket *socket);
104KORE_FUNC
bool kore_socket_listen(
kore_socket *socket,
int backlog);
105KORE_FUNC
bool kore_socket_accept(
kore_socket *socket,
kore_socket *new_socket,
unsigned *remote_address,
unsigned *remote_port);
108KORE_FUNC
bool kore_socket_connect(
kore_socket *socket);
110KORE_FUNC
int kore_socket_send(
kore_socket *socket,
const uint8_t *data,
int size);
111KORE_FUNC
int kore_socket_send_address(
kore_socket *socket,
unsigned address,
int port,
const uint8_t *data,
int size);
112KORE_FUNC
int kore_socket_send_url(
kore_socket *socket,
const char *url,
int port,
const uint8_t *data,
int size);
113KORE_FUNC
int kore_socket_receive(
kore_socket *socket, uint8_t *data,
int maxSize,
unsigned *from_address,
unsigned *from_port);
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
KORE_FUNC void kore_socket_parameters_set_defaults(kore_socket_parameters *parameters)
Initializes a socket-options-object to the default parameters.
KORE_FUNC void kore_socket_init(kore_socket *socket)
Initializes a socket-object. To set the host and port use kore_socket_set. Host will be localhost Por...
KORE_FUNC bool kore_socket_open(kore_socket *socket, const kore_socket_parameters *parameters)
Opens a socket-connection.
KORE_FUNC bool kore_socket_set(kore_socket *socket, const char *host, int port, kore_socket_family family, kore_socket_protocol protocol)
Sets the sockets properties.
KORE_FUNC unsigned kore_url_to_int(const char *url, int port)
Resolves a DNS-entry to an IP and returns its integer representation.
KORE_FUNC bool kore_socket_select(kore_socket *socket, uint32_t waittime, bool read, bool write)
For use with non-blocking sockets to try to see if we are connected.
KORE_FUNC void kore_socket_destroy(kore_socket *socket)
Destroys a socket-object.