-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.c
More file actions
38 lines (28 loc) · 780 Bytes
/
server.c
File metadata and controls
38 lines (28 loc) · 780 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
32
33
34
35
36
37
38
/**
* Projekt c.3 do predmetu IPK
* @author Jan Dusek <xdusek17@stud.fit.vutbr.cz>
* @date 18.4.2011
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include "rdt.h"
#include "args.h"
#define MAX_LINE_SIZE 81
in_addr_t REMOTE_ADDR = 0x7f000001;
static const char *USAGE = "rdtserver -s SOURCE_PORT -d DEST_PORT";
int main(int argc, char **argv) {
args_usage = USAGE;
args_t args;
if (parse_args(argc, argv, &args) == -1)
return 1;
rdt_t *rdt = rdt_create(args.source_port);
rdt_listen(rdt, args.dest_port);
fprintf(stderr, "Connection established\n");
if (rdt_recv(rdt, stdout) == -1)
fprintf(stderr, "Error recieving to stream\n");
rdt_close(rdt);
return 0;
}