-
Notifications
You must be signed in to change notification settings - Fork 2
/
netio.c
57 lines (50 loc) · 1012 Bytes
/
netio.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
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "netio.h"
#include "error.h"
#include "help.h"
#include "params.h"
#include "net.h"
#include "io.h"
#include "mainloop.h"
#include "signals.h"
#include "mkserver.h"
#include "servers.h"
#include "mkclient.h"
#include "clients.h"
int main(int argc, char* argv[])
{
if ( argc < 2 )
{
help();
exit( EXIT_FAILURE );
}
signals_init();
params( argc, argv );
io_init();
int index;
int proto;
if ( p_server )
{
for (index = 0; index < p_targetc; ++index)
{
int server_sock = mkserver( p_targetv[index], &proto );
if ( net_params[proto].m_type == SOCK_STREAM )
server_add( server_sock );
else
client_add( server_sock );
}
}
else
{
for (index = 0; index < p_targetc; ++index)
{
int client_sock = mkclient( p_targetv[index], &proto );
client_add( client_sock );
}
}
mainloop();
return 0;
};