-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockchainMain.c
59 lines (52 loc) · 1.13 KB
/
blockchainMain.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
58
59
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/errno.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "blockchain.h"
// create both a client and publisher now
int main(int argc, char **argv)
{
int blockCount = 0;
if (argc < 2)
errexit("usage: TCPechod [port]\n");
char *service = argv[1];
int i = 2, j = 0;
const int hostCount= argc - 2;
char *hosts[hostCount];
for (; i < argc, j < hostCount; i++, j++)
{
hosts[j] = argv[i];
}
(void) signal(SIGCHLD, reaper);
if (fork() == 0)
{
//child = server
if (server(service) == 1)
{
errexit("Server Error\n Closing Program\n");
}
}
else {
//parent = client
while (1)
{
//system("clear");
printf("\n\tPress ENTER to launch UI\n");
fflush(stdout);
getchar();
//int client(const int numHosts, char **hosts, char *sock);
client(hostCount, hosts, service);
}
}
}