diff options
Diffstat (limited to 'daemon/fromd/fromc.c')
-rw-r--r-- | daemon/fromd/fromc.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/daemon/fromd/fromc.c b/daemon/fromd/fromc.c new file mode 100644 index 00000000..1a5cb6b1 --- /dev/null +++ b/daemon/fromd/fromc.c @@ -0,0 +1,38 @@ +// $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]; + + 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[2], strlen(argv[2])); + read(fd, buf, sizeof(buf)); + + printf("%s\n", buf); + + return 0; +} + + |