-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon_socket.h
47 lines (35 loc) · 1.18 KB
/
common_socket.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef COMMON_SOCKET_H
#define COMMON_SOCKET_H
#include <stdlib.h>
#include <stdbool.h>
struct socket {
char* host;
char* port;
int skt;
int current_peerskt;
struct addrinfo *result;
};
/*
Crea e incializa el socket definiendo la familia, el tipo de socket y el
protocolo para poder conectarse al cliente por medio del port y host indicados
*/
void socket_create(struct socket *self, char* _host, char* _port);
/*
Almacena los parametros necesarios para la incialización del socket.
*/
bool socket_start(struct socket *self);
bool socket_connect_with_clients(struct socket *self);
void socket_destroy(struct socket *self);
int socket_accept_client(struct socket *self);
int socket_receive_some(struct socket *self, char* buf, \
size_t size);
int socket_send_all(struct socket *self, \
size_t request_len, char*request);
/*
Desactiva las operaciones de envío y recepción para el cliente y para si mismo
*/
void socket_disable_client(struct socket *self);
//desabilita el canal de escritura
void socket_disables_send_operations(struct socket *self);
bool socket_connect_with_server(struct socket *self);
#endif