-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistener_socket.h
More file actions
31 lines (27 loc) · 977 Bytes
/
listener_socket.h
File metadata and controls
31 lines (27 loc) · 977 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
26
27
28
29
30
31
#pragma once
typedef struct Listener_Socket Listener_Socket_t;
/** @brief Initializes a listener socket that listens on the provided
* port on all of the interfaces for the host.
*
* @param port The port on which to listen.
*
* @return a pointer to the listener socket, indicating success, or NULL,
* indicating that it failed to listen.
*/
Listener_Socket_t *ls_new(int port);
/** @brief Destory the listener socket.
*
* @param ppls a pointer to the pointer to destory. Cleans its memory and
* assigns the pointer to be NULL.
*
*/
void ls_delete(Listener_Socket_t **ppls);
/** @brief Accept a new connection and initialize a 5 second timeout
*
* @param pls A pointer to the Listener_Socket from which to get the new
* connection.
*
* @return An socket for the new connection, or -1, if there is an
* error. Sets errno according to any errors that occur.
*/
int ls_accept(Listener_Socket_t *pls);