On 22/05/15 23:15, Andrew Stuart wrote:
Spoke too soon!
After a reboot I did get a console log. I’m not quite sure what’s happening.
The telnet connection seems to start but I’m not getting data back.
Martin - what would be a help here is if I had a second server app to try - you
seem pretty up to speed with building servers - if you can put together a
Makefile for some sort of application server that does not use a disk at all
and talks back over a network then I will have a second server to try to make
sure it is not my telnet chat application server at fault. Even a simple
daytime server or something that returns current time on port 13 would do the
job. Or a simple HTTP server that spits back some sort of response and
definitely no chance speaks to a disk. If you have time to do that it would
save me alot of time and allow me to focus on the EC2 aspects.
You forget that there's a regular unix API "over the hood" and you can
use just any simple program, e.g. a completely handwritten dummy
program. That's in fact what I would've started from. For example,
consider the attached simple program.
pooka@watou:~$ rumprun-bmk-cc -o servtest simple.c
pooka@watou:~$ rumprun kvm -I iftag,vioif,'-net tap,ifname=tap0' -W
iftag,inet,static,10.0.0.2/24 servtest
!!!
!!! NOTE: rumprun is experimental and may change in the future
!!!
qemu:13681
pooka@watou:~$ nc 10.0.0.2 11223
no hei vaan
pooka@watou:~$
It's extremely simple, doesn't use disk, you don't even need a Makefile,
and you can very very easily modify it to suit your testing.
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <err.h>
#include <string.h>
#include <unistd.h>
int
main()
{
struct sockaddr_in sin;
int s;
s = socket(PF_INET, SOCK_STREAM, 0);
if (s == -1)
err(1, "socket");
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(11223);
sin.sin_addr.s_addr = INADDR_ANY;
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) == -1)
err(1, "bind");
if (listen(s, 20) == -1)
err(1, "listen");
#define HSTR "no hei vaan\n"
for (;;) {
struct sockaddr_in sincli;
socklen_t slen;
int s2;
slen = sizeof(sincli);
if ((s2 = accept(s, (struct sockaddr *)&sincli, &slen)) == -1)
err(1, "accept");
if (write(s2, HSTR, sizeof(HSTR)-1) != sizeof(HSTR)-1)
errx(1, "write returned unexpected result");
close(s2);
}
}