aboutsummaryrefslogtreecommitdiff
path: root/src/socket.h
blob: 69c2690dcb58e23e99cd111246beed445c4961ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef POTD_SOCKET_H
#define POTD_SOCKET_H 1

#include <netdb.h>

#define POTD_BACKLOG 3

typedef struct psocket {
    int fd;
    socklen_t addr_len;
    struct sockaddr addr;
} psocket;


int socket_init_in(const char *listen_addr,
                   const char *listen_port, struct addrinfo **results);

int socket_bind_in(psocket *psock, struct addrinfo *results);

int socket_listen_in(psocket *psock);

int socket_accept_in(const psocket *psock, psocket *client_psock);

int socket_addrtostr_in(const psocket *psock,
                        char hbuf[NI_MAXHOST], char sbuf[NI_MAXSERV]);

#endif