summaryrefslogtreecommitdiffstats
path: root/sock_stuff.h
blob: 01082d1c83ed189303a1a96d0059881daa4967b2 (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 __SOCK_STUFF_H
#define __SOCK_STUFF_H

#include <stdint.h>

enum fd_mode
{
    fdread,
    fdwrite,
    fdexcept
};
typedef enum fd_mode fd_mode;

int create_unix_socket(const char *filename);
int connect_unix_socket(const char *filename);
int create_socket(uint16_t port);
int connect_socket(const char *addr, uint16_t port);
int check_fd(int fd, fd_mode fdm, unsigned int timeout);

int recv_buf(int fd, void *data, size_t size);
int peek_buf(int fd, void *data, size_t size);
int recv_buf_timeout(int fd, void *data, size_t size, int flags, unsigned int timeout);

int send_buf(int fd, void *data, size_t size);

#endif /* __SOCK_STUFF_H */