This file Defines everything related to networking.
More...
Go to the source code of this file.
|
void | snf_network_init () |
| Initializes the Network Framwork.
|
|
void | snf_network_join () |
| See snf_thpool_join.
|
|
int | snf_snd (SNF_CLT *Client, const char *Buffer, int _Size) |
| Sends a Buffer to Client's socket's file descriptor.
|
|
int | snf_rcv_ (SNF_CLT *Client, void *Buffer, int _Size, int _Flags) |
| Receives a Buffer from Client's socket's file descriptor.
|
|
This file Defines everything related to networking.
◆ SNF_Total_Data
Macro that defines the Total data tranferred so far.
- Warning
- Innacurate for now
◆ UNIT_SCEPARATOR
#define UNIT_SCEPARATOR "\x1F" |
Character that sceparates each argument (To be Removed)
◆ snf_rcv
#define snf_rcv |
( |
| Client, |
|
|
| Buffer, |
|
|
| _Size ) |
Value:
int snf_rcv_(SNF_CLT *Client, void *Buffer, int _Size, int _Flags)
Receives a Buffer from Client's socket's file descriptor.
Same as snf_rcv_ how ever _Flags will be 0.
◆ snf_rcv_PEEK
#define snf_rcv_PEEK |
( |
| Client, |
|
|
| Buffer, |
|
|
| _Size ) |
Value:snf_rcv_(Client, Buffer, _Size, MSG_PEEK)
Same as snf_rcv_ how ever _Flags will be MSG_PEEK.
◆ snf_network_init()
void snf_network_init |
( |
| ) |
|
|
extern |
Initializes the Network Framwork.
◆ snf_network_join()
void snf_network_join |
( |
| ) |
|
|
extern |
◆ snf_snd()
int snf_snd |
( |
SNF_CLT * | Client, |
|
|
const char * | Buffer, |
|
|
int | _Size ) |
|
extern |
Sends a Buffer to Client's socket's file descriptor.
- Parameters
-
Client | Pointer to the Client's SNF_CLT instance |
Buffer | Buffer to send |
_Size | Size of the Buffer (See Note ) |
- Returns
- The following possible results:
- -1 Client Could be NULL, or In case of an Error , Check errno and compare it to send's possible Errors, if errno == EPIPE then ignore it as it was already dealt with.
- int The amount of data sent.
- Note
- The _Size parameter could react differently depeding on it's value
- If _Size < 0 then it will assume the Buffer is a string and send 4 bytes indicating the size (See snf_uint32_to_bytes on how those 4 bytes are written ) and then send the buffer.
- else it will send the Buffer and the length will be _Size
◆ snf_rcv_()
int snf_rcv_ |
( |
SNF_CLT * | Client, |
|
|
void * | Buffer, |
|
|
int | _Size, |
|
|
int | _Flags ) |
|
extern |
Receives a Buffer from Client's socket's file descriptor.
- Parameters
-
Client | Pointer to the Client's SNF_CLT instance |
Buffer | Received Buffer |
_Size | Expected Size |
_Flags | Flags that will be passed to recv() |
- Returns
- The following possible results:
- -1 Client Could be NULL, or In case of an Error , Check errno and compare it to send's possible Errors, if errno == EPIPE then ignore it as it was already dealt with.
- int The amount of data sent.
- Warning
- If you receive n amount of bytes and is lower than _Size , it will assume that recv has failed and will check errno, as it could disconnect the client in somecases and the function will return -1.
- Note
- There is are re-definitions of snf_recv_ and are:
◆ SNF_SERVER_SOCKET
the main Socket that accepts new incoming connections
- Warning
- Do not modify it's contents unless you know what you're doing.
◆ SNF_SERVER_ADDR
struct sockaddr_in SNF_SERVER_ADDR |
|
extern |
Structure that saves the Server's sockaddr_in.
- Warning
- Do not modify it's contents unless you know what you're doing.
◆ SNF_CLIENT_ADDR
struct sockaddr_in SNF_CLIENT_ADDR |
|
extern |
Structure that saves the Client's sockaddr_in.
- Warning
- Do not modify it's contents unless you know what you're doing.
◆ SNF_CLIENT_LEN
Used for accept's length argument.
- Warning
- Do not modify it's contents unless you know what you're doing.
◆ SNF_Total_Data_Rcv
_Atomic uint64_t SNF_Total_Data_Rcv |
|
extern |
Saves the Total data received so far.
- Warning
- Innacurate for now
◆ SNF_Total_Data_Snt
_Atomic uint64_t SNF_Total_Data_Snt |
|
extern |
Saves the Total data sent so far.
- Warning
- Innacurate for now