http server
This commit is contained in:
@@ -15,15 +15,9 @@ main :: () -> s32 {
|
||||
opt : s32 = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, @opt, 4);
|
||||
|
||||
addr := SockAddr.{
|
||||
sin_len = 16,
|
||||
sin_family = 2,
|
||||
sin_port = htons(PORT),
|
||||
sin_addr = 0,
|
||||
sin_zero = 0
|
||||
};
|
||||
addr := SockAddr.{ sin_len = 16, sin_family = 2, sin_port = htons(PORT) };
|
||||
|
||||
if bind(fd, @addr, 16) < 0 {
|
||||
if bind(fd, addr, 16) < 0 {
|
||||
print("error: bind()\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -40,8 +34,8 @@ main :: () -> s32 {
|
||||
if client < 0 { continue; }
|
||||
|
||||
// Read request
|
||||
buf := alloc(4096);
|
||||
read(client, buf, 4096);
|
||||
buf : [4096]u8 = ---;
|
||||
read(client, buf, buf.len);
|
||||
|
||||
// Send response
|
||||
body := "<html><body><h1>Hello from sx!</h1></body></html>";
|
||||
|
||||
Reference in New Issue
Block a user