summaryrefslogtreecommitdiffstats
path: root/daemon/fromd/fromc.c
blob: 5ad3f7f104add3a55d46e73ec91d6f65e455db6a (plain) (blame)
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
// $Id$
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "bbs.h"

// standalone client to test fromd

int main(int argc, char *argv[])
{
    int port, fd;
    char buf[64];

    memset(buf, 0, sizeof(buf));

    if (argc < 4) {
    fprintf(stderr, "Usage: %s ip port lookup_ip\n", argv[0]);
    return 0;
    }

    if ( (port = atoi(argv[2])) == 0 ) {
    fprintf(stderr, "Port given is not valid\n");
    return 1;
    }

    if ( (fd = toconnect(argv[1], port)) < 0 ) {
    perror("toconnect");
    return 1;
    }

    write(fd, argv[3], strlen(argv[3]));
    read(fd, buf, sizeof(buf));

    printf("%s\n", buf);

    return 0;
}