otp_socket.c
Include dependency graph for otp_socket.c:
Defines
-
CLOSED_FD
-
ADDR_ATOM
-
CLOSE_INTERNAL_ATOM
-
ACCEPT_ATOM
-
RECV_ATOM
-
DEFAULT_BUFFER_SIZE
-
MIN(A, B)
Enums
Functions
-
static void socket_down(ErlNifEnv *caller_env, void *obj, ErlNifPid *pid, ErlNifMonitor *mon)
-
void otp_socket_init(GlobalContext *global)
-
static inline int get_domain(GlobalContext *global, term domain_term, bool *ok)
-
static inline int get_type(GlobalContext *global, term type_term, bool *ok)
-
static inline int get_protocol(GlobalContext *global, term protocol_term, bool *ok)
- switch (level_val)
- if (UNLIKELY(memory_ensure_free(ctx, TUPLE_SIZE(2)+term_map_size_in_terms(2)+TUPLE_SIZE(4)) !=MEMORY_GC_OK))
- term_set_map_assoc (map, 0, ADDR_ATOM, address)
- term_set_map_assoc (map, 1, PORT_ATOM, port_number)
Variables
-
static const char *const addr_atom = ATOM_STR("\x4", "addr")
-
static const char *const any_atom = ATOM_STR("\x3", "any")
-
static const char *const invalid_option_atom = ATOM_STR("\xE", "invalid_option")
-
static const char *const invalid_value_atom = ATOM_STR("\xD", "invalid_value")
-
static const char *const linger_atom = ATOM_STR("\x6", "linger")
-
static const char *const loopback_atom = ATOM_STR("\x8", "loopback")
-
static const char *const onoff_atom = ATOM_STR("\x5", "onoff")
-
static const char *const port_atom = ATOM_STR("\x4", "port")
-
static const char *const rcvbuf_atom = ATOM_STR("\x6", "rcvbuf")
-
static const char *const reuseaddr_atom = ATOM_STR("\x9", "reuseaddr")
-
static const AtomStringIntPair otp_socket_shutdown_direction_table[] = {{ATOM_STR("\x4", "read"), OtpSocketReadShutdownDirection}, {ATOM_STR("\x5", "write"), OtpSocketWriteShutdownDirection}, {ATOM_STR("\xA", "read_write"), OtpSocketReadWriteShutdownDirection},}
-
static const AtomStringIntPair otp_socket_setopt_level_table[] = {{ATOM_STR("\x6", "socket"), OtpSocketSetoptLevelSocket}, {ATOM_STR("\x3", "otp"), OtpSocketSetoptLevelOTP},}
-
static ErlNifResourceType *socket_resource_type
- static const ErlNifResourceTypeInit SocketResourceTypeInit = {.members = 3,.dtor = socket_dtor,.stop = NULL,.down = socket_down,}
-
term level = term_get_tuple_element(level_tuple, 0)
-
int level_val = interop_atom_term_select_int(otp_socket_setopt_level_table, level, global)
- else = { term address = inet_make_addr4(ip4_u32, &ctx->heap)
-
term port_number = term_from_int(port_u16)
-
term map = term_alloc_map(2, &ctx->heap)
-
term return_value = port_create_tuple2(ctx, OK_ATOM, map)
- static const struct Nif socket_open_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_open}
- static const struct Nif socket_close_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_close}
- static const struct Nif socket_select_stop_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_select_stop}
- static const struct Nif socket_setopt_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_setopt}
- static const struct Nif socket_bind_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_bind}
- static const struct Nif socket_listen_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_listen}
- static const struct Nif socket_sockname_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_sockname}
- static const struct Nif socket_peername_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_peername}
- static const struct Nif socket_select_read_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_select_read}
- static const struct Nif socket_accept_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_accept}
- static const struct Nif socket_recv_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_recv}
- static const struct Nif socket_recvfrom_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_recvfrom}
- static const struct Nif socket_send_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_send}
- static const struct Nif socket_sendto_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_sendto}
- static const struct Nif socket_connect_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_connect}
- static const struct Nif socket_shutdown_nif = {.base.type =NIFFunctionType,.nif_ptr = nif_socket_shutdown}