9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] serving html sites with announce, listen and accept (dial(2))
@ 2024-09-09  5:57 sahu
  2024-09-09  6:10 ` Alex Musolino
  0 siblings, 1 reply; 6+ messages in thread
From: sahu @ 2024-09-09  5:57 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 1855 bytes --]

hello everyone, 

I’ve made some small changes to the bekremvax-example in dial(2) in order to get a simple html response:

#include <u.h>
#include <libc.h>

int
bekremvax(void)
{
	int dfd, acfd, lcfd;
	char adir[40], ldir[40];
	int n;
	char *buf = „HTTP/1.1 200 OK\nContent-Type: text/html; charset=UTF-8\nContent-Length: 8\n\n<!DOCTYPE html><html><body>hello, world!</body></html>";
	acfd = announce("tcp!*!7", adir);
        if(acfd < 0)
        	return -1;
        for(;;){
        	/* listen for a call */
                lcfd = listen(adir, ldir);

                if(lcfd < 0)
                	return -1;
                /* fork a process to echo */
                switch(fork()){
                case -1:
                	perror("forking");
                        close(lcfd);
                        break;
                case 0:
                	/* accept the call and open the data file */
                        dfd = accept(lcfd, ldir);
                        if(dfd < 0)
                        	return -1;
			print(„incoming request“);
                        write(dfd, buf, sizeof(buf));
                        exits(nil);
                default:
                	close(lcfd);
                        break;
                }
	}
}
void
main()
{
	bekremvax();
	exits(nil);
}

in my browser I’m getting an empty page and with netcat the following output:
nc -v 10.211.55.3 7

Connection to 10.211.55.3 port 7 [tcp/discard] succeeded!

HTTP/1.1%      

there is also no print statement („incoming request“) when I’m trying to reach the service via browser. am I doing something wrong? 9front is running in a vm at the moment, but as far as I can tell there weren’t any issues regarding the network.

thank you very much in advance!

best regards, 
Sascha

[-- Attachment #2: Type: text/html, Size: 13533 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-09 10:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-09  5:57 [9front] serving html sites with announce, listen and accept (dial(2)) sahu
2024-09-09  6:10 ` Alex Musolino
2024-09-09  7:28   ` sahu
2024-09-09  8:12     ` sirjofri
2024-09-09  9:09       ` sahu
2024-09-09 10:10         ` sirjofri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).