GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Win32 C network library for AFTI students
Homepage: http://opk.afti.ru
Clone URL: git://github.com/be9/networq.git
oleg dashevskii (author)
Fri May 16 00:13:03 -0700 2008
networq / network.h
100644 33 lines (23 sloc) 0.818 kb
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
#ifndef __network_h
#define __network_h
 
#include <Winsock2.h>
 
/* initialize network. returns 0 on success */
int nw_init(void);
 
/* shutdown */
void nw_shutdown(void);
 
/* create socket and set to listening mode. returns 0 on success */
int nw_listen(SOCKET *sock, int port);
 
/* close a socket */
void nw_closesocket(SOCKET s);
 
typedef void (*accept_callback_t)(SOCKET client_sock, const char *client_ip, u_short client_port);
 
/* run accepting loop.
 * accepts connections on accept_sock till hExit is signaled
 * upon accepting the connection callback is called
 */
int nw_accept_loop(SOCKET accept_sock, HANDLE h_exit, accept_callback_t callback);
 
/*
 * install console handler reacting to various break events by signaling an event
 * returns event handle
 */
HANDLE nw_install_break_handler(void);
 
#endif