2021-04-02-Fri-Study
Apr 2, 2021
»
study
Network
memset
The memset function is used when you want to assign a value to a contiguous memory in a specific range, it can be faster than the for statement.
(can be -> because it depends on compiler and computer architecture)
#include <string.h>
void * memset ( void * ptr, int value, size_t num );
ptr : Start pointer (start address) of memory to be filled
value: The value you want to fill in the memory. Although it is int type, it is converted to unsigned char (1 byte) and stored internally.
num: The number of bytes to fill. In other words, the amount of memory to be filled
ex) memset(char ptr[20], 26, sizeof(ptr));
int socket(int domain, int type, int protocol);
domain: protocol family to use
type: type of socket to use in the protocol
protocol: udp or tcp
socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
Make UDP Socket
PF_INET: IPv4 Internet Protocol Family
SOCK_DGRAM: Datagram Socket
IPPROTO_UDP: Datagram Socket