forked from hugsy/proxenet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket.h
More file actions
25 lines (20 loc) · 943 Bytes
/
socket.h
File metadata and controls
25 lines (20 loc) · 943 Bytes
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
#ifndef _SOCKET_H
#define _SOCKET_H
typedef int sock_t;
#define MAX_CONN_SIZE 10
#define MAX_READ_SIZE 4095
#define MAX_CONNECT_ATTEMPT 5
#define ECONNREFUSED_MSG "Server refused connection (closed port?)"
#define EHOSTUNREACH_MSG "Server is not reachable"
#include "ssl.h"
char* proxenet_resolve_hostname(char* hostname, int type);
sock_t proxenet_bind_control_socket();
sock_t proxenet_bind_socket(char *host, char* port);
sock_t proxenet_open_socket(char *host, char* port);
int proxenet_close_socket(sock_t sock, ssl_atom_t* ssl_atom);
ssize_t proxenet_write(sock_t sock, void *buf, size_t count);
ssize_t proxenet_read(sock_t sock, void *buf, size_t count);
int proxenet_read_all(sock_t sock, char** ptr, proxenet_ssl_context_t* ssl_sess);
int get_ip_address_from_fd(unsigned char* ip, int iplen, int fd);
int get_port_from_fd(sock_t fd);
#endif /* _SOCKET_H */