mirror of
https://github.com/Hizenberg469/Event-Loop-in-C.git
synced 2026-04-20 09:12:24 +03:00
Project Finished
This commit is contained in:
48
asyncproject/network_utils.h
Normal file
48
asyncproject/network_utils.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef __NETWORK_UTILS__
|
||||
#define __NETWORK_UTILS__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <memory.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define MAX_PACKET_BUFFER_SIZE 1024
|
||||
|
||||
typedef void (*recv_fn_cb)(char*, /* msg recvd */
|
||||
uint32_t, /* recvd msg size */
|
||||
char*, /* Sender's IP address */
|
||||
uint32_t, /* Sender's Port number */
|
||||
uint32_t); /* Sender Communication FD , only for tcp*/
|
||||
|
||||
void
|
||||
udp_server_create_and_start(
|
||||
char* ip_addr,
|
||||
uint32_t udp_port_no,
|
||||
recv_fn_cb recv_fn);
|
||||
|
||||
int
|
||||
send_udp_msg(char* dest_ip_addr,
|
||||
uint32_t udp_port_no,
|
||||
char* msg,
|
||||
uint32_t msg_size,
|
||||
int sock_fd);
|
||||
|
||||
/* General Nw utilities */
|
||||
char*
|
||||
network_covert_ip_n_to_p(uint32_t ip_addr,
|
||||
char* output_buffer);
|
||||
|
||||
uint32_t
|
||||
network_covert_ip_p_to_n(char* ip_addr);
|
||||
|
||||
#endif /* __NETWORK_UTILS__ */
|
||||
Reference in New Issue
Block a user