-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.c
44 lines (37 loc) · 889 Bytes
/
common.c
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
#include "common.h"
#include <winsock2.h>
#include <windows.h>
#include "logmsg.h"
#include "error.h"
#include "server.h"
int start_server
(
struct lappenchat_server_options lcso,
HANDLE stop_event
)
{
int rv;
if ( WSAStartup(MAKEWORD(2,2), &lcso.wsa_data) == 0 )
{
logmsgf("successfully initialized Winsock\nWinsock version offered: %u.%u\nWinsock implementation description: %s\n", LOBYTE(lcso.wsa_data.wVersion), HIBYTE(lcso.wsa_data.wVersion), lcso.wsa_data.szDescription);
rv = lappenchat_server(lcso, stop_event);
if ( WSACleanup() == 0 )
logmsg("successfully terminated use of Winsock");
else
wsa_perror("couldn't terminate use of Winsock");
}
else
{
logmsg("couldn't initialize Winsock");
rv = 0;
}
return rv;
}
size_t
get_proc_n
( void )
{
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
return system_info.dwNumberOfProcessors;
}