my_teams
|
#include <netinet/in.h>
#include <sys/queue.h>
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | p_network_data_s |
Represents network data including socket file descriptor and server address. More... | |
struct | p_packet_s |
Represents a packet with type and data. More... | |
struct | p_payload_s |
Represents a payload containing packet, network data, and actual data. More... | |
struct | p_client_s |
Represents a client with socket file descriptor and network data. More... | |
struct | p_server_s |
Represents a server with network data, file descriptor set, and list of clients. More... | |
Macros | |
#define | DATA_SIZE 4096 |
Typedefs | |
typedef struct p_network_data_s | p_network_data_t |
typedef struct p_packet_s | p_packet_t |
typedef struct p_payload_s | p_payload_t |
typedef struct p_client_s | p_client_t |
typedef struct p_server_s | p_server_t |
Functions | |
p_client_t * | p_client_create (const char *ip, int port) |
Create a client with given IP and port. More... | |
p_payload_t * | p_client_listen (p_client_t *client) |
Listen for incoming packets on the client. More... | |
bool | p_client_send_packet (const p_client_t *client, uint16_t type, const void *data, int size) |
Send a packet from the client. More... | |
p_server_t * | p_server_create (int port) |
Create a server with given port. More... | |
p_payload_t * | p_server_listen (p_server_t *server) |
Listen for incoming packets on the server. More... | |
bool | p_server_send_packet (const p_packet_t *packet, int client_fd, p_server_t *server) |
Send a packet from the server to a specific client. More... | |
bool | p_server_send_packet_type (uint16_t type, int client_fd, p_server_t *server) |
Send a packet from the server to a specific client. More... | |
p_payload_t * | p_create_payload (uint16_t packet_type, const void *payload_data) |
Create a payload with given packet type, data, and size. More... | |
bool | new_client (p_server_t *server) |
Create a new client on the server. More... | |
bool | select_server (p_server_t *server) |
Select the server for incoming packets. More... | |
bool | server_bind (p_server_t *server) |
Bind the server to the given port. More... | |
bool | server_listen (p_server_t *server) |
Listen for incoming connections on the server. More... | |
bool | server_setsockopt (p_server_t *server) |
Set socket options for the server. More... | |
p_server_t * | server_socket (int port) |
Create a socket for the server. More... | |
p_client_t * | get_client (int fd, const p_server_t *server) |
Get the client with the given file descriptor. More... | |
void | p_server_close (p_server_t *server) |
Close the server. More... | |
bool | p_server_is_open (void) |
Check if the server is open. More... | |
void | p_client_close (p_client_t *client) |
Close the client. More... | |
#define DATA_SIZE 4096 |
typedef struct p_client_s p_client_t |
typedef struct p_network_data_s p_network_data_t |
typedef struct p_packet_s p_packet_t |
typedef struct p_payload_s p_payload_t |
typedef struct p_server_s p_server_t |
p_client_t* get_client | ( | int | fd, |
const p_server_t * | server | ||
) |
Get the client with the given file descriptor.
fd | File descriptor of the client. |
server | Pointer to the server. |
bool new_client | ( | p_server_t * | server | ) |
Create a new client on the server.
server | Pointer to the server. |
void p_client_close | ( | p_client_t * | client | ) |
Close the client.
client | Pointer to the client. |
p_client_t* p_client_create | ( | const char * | ip, |
int | port | ||
) |
Create a client with given IP and port.
ip | IP address of the server. |
port | Port number of the server. |
p_payload_t* p_client_listen | ( | p_client_t * | client | ) |
Listen for incoming packets on the client.
client | Pointer to the client. |
bool p_client_send_packet | ( | const p_client_t * | client, |
uint16_t | type, | ||
const void * | data, | ||
int | size | ||
) |
Send a packet from the client.
client | Pointer to the client. |
type | Type of the packet. |
data | Data to be included in the packet. |
size | Size of the data. |
p_payload_t* p_create_payload | ( | uint16_t | packet_type, |
const void * | payload_data | ||
) |
Create a payload with given packet type, data, and size.
packet_type | Type of the packet. |
payload_data | Data to be included in the payload. |
void p_server_close | ( | p_server_t * | server | ) |
Close the server.
server | Pointer to the server. |
p_server_t* p_server_create | ( | int | port | ) |
Create a server with given port.
port | Port number to bind the server. |
bool p_server_is_open | ( | void | ) |
Check if the server is open.
p_payload_t* p_server_listen | ( | p_server_t * | server | ) |
Listen for incoming packets on the server.
server | Pointer to the server. |
bool p_server_send_packet | ( | const p_packet_t * | packet, |
int | client_fd, | ||
p_server_t * | server | ||
) |
Send a packet from the server to a specific client.
packet | Pointer to the packet to be sent. |
client_fd | File descriptor of the client. |
server | Pointer to the server. |
bool p_server_send_packet_type | ( | uint16_t | type, |
int | client_fd, | ||
p_server_t * | server | ||
) |
Send a packet from the server to a specific client.
type | Type of the packet. |
client_fd | File descriptor of the client. |
server | Pointer to the server. |
bool select_server | ( | p_server_t * | server | ) |
Select the server for incoming packets.
server | Pointer to the server. |
bool server_bind | ( | p_server_t * | server | ) |
Bind the server to the given port.
server | Pointer to the server. |
bool server_listen | ( | p_server_t * | server | ) |
Listen for incoming connections on the server.
server | Pointer to the server. |
bool server_setsockopt | ( | p_server_t * | server | ) |
Set socket options for the server.
server | Pointer to the server. |
p_server_t* server_socket | ( | int | port | ) |
Create a socket for the server.
port | Port number to bind the server. |