summaryrefslogtreecommitdiffstats
path: root/socket.h
blob: 35e955128e8553ebdfb533ba2c8f4d6cb6cd775a (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef _SOCKET_H
#define _SOCKET_H

#include "uint.h"

/* accept a connection, returns socket fd, ip and port */
int socket_accept4(int s, char *ip, u16 *port);

/* bind s to local ip and port */
int socket_bind4(int s, char *ip, u16 port);

/* set SO_REUSEADDR before calling socket_bind4 */
int socket_bind4_reuse(int s, char *ip, u16 port);

/* connect s to ip and port */
int socket_connect4(int s, const char *ip, u16 port);

/* return 1 if connected */
int socket_connected(int s);

/* reset socket options */
int socket_ipoptionskill(int s);

/* just call listen */
int socket_listen(int s,int backlog);

/* get local ip and port */
int socket_local4(int s, char *ip, u16 *port);

/* feed buffer ip and port */
int socket_recv4(int s, char *,int,char *ip, u16 *port);

/* get distant ip and port */
int socket_remote4(int s, char *ip, u16 *port);

/* send buffer to ip and port */
int socket_send4(int s, const char *,int,const char *ip, u16 port);

/* returns a sock-stream socket if(!block) set O_NONBLOCK */
int socket_tcp(int block);

/* set TCP_NODELAY */
int socket_tcpnodelay(int s);

/* try to set input buffer size */
void socket_tryreservein(int s, int size);

/* returns a sock-dgram socket if(!block) set O_NONBLOCK */
int socket_udp(int block);

#endif