This is a very simple HTTP server for Unix, using fork(). It's very easy to use
- include header
httpd.h - write your route method, handling requests.
- call
serve_forever("12913")to start serving on port 12913
| /* | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| */ | |
| #include <arpa/inet.h> | |
| #include <linux/if_packet.h> | |
| #include <stdio.h> |
| body { | |
| font-family: Helvetica, arial, sans-serif; | |
| font-size: 14px; | |
| line-height: 1.6; | |
| padding-top: 10px; | |
| padding-bottom: 10px; | |
| background-color: white; | |
| padding: 30px; } | |
| body > *:first-child { |
| /** | |
| * More info? | |
| * a.dotreppe@aspyct.org | |
| * http://aspyct.org | |
| * | |
| * Hope it helps :) | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> |
| ; This is a snippet of the original file in https://github.com/geyslan/SLAE/blob/master/1st.assignment/shell_bind_tcp.asm | |
| global _start | |
| section .text | |
| _start: | |
| ; syscalls (/usr/include/asm/unistd_32.h) | |
| ; socketcall numbers (/usr/include/linux/net.h) |
| ;----------------------------------------------; | |
| ; | |
| ; A minimal bootloader that prints a hello world | |
| ; then halts. | |
| ; | |
| ; nasm -f bin hello-boot.asm -o hello-boot.bin | |
| ; | |
| ; @YouriAckx | |
| ; | |
| ;----------------------------------------------; |
| /* | |
| C socket server example, handles multiple clients using threads | |
| Compile | |
| gcc server.c -lpthread -o server | |
| */ | |
| #include<stdio.h> | |
| #include<string.h> //strlen | |
| #include<stdlib.h> //strlen | |
| #include<sys/socket.h> |
| /* | |
| An example of using raw sockets. | |
| You can capture packets by tcpdump: | |
| tcpdump -X -s0 -i lo -p udp | |
| */ | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #include <stdio.h> |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "io" | |
| "log" | |
| "net" | |
| "os" | |
| "os/signal" |
| # ref: https://play.golang.org/p/OeEmT_CXyO | |
| package main | |
| import ( | |
| "fmt" | |
| "runtime" | |
| "strconv" | |
| "strings" | |
| "sync" | |
| ) |