This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "simple-web-server" | |
version = "0.1.0" | |
authors = ["James Benner <[email protected]>"] | |
[dependencies] | |
time = "0.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)?)__([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)?)(?:--)([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)?)$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int server_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct sockaddr_in server_addr = { | |
.sin_family = AF_INET, // Address family | |
.sin_addr.s_addr = htonl(INADDR_ANY), // Any incoming address | |
.sin_port = htons(server_port) // Local server port | |
}; | |
memset(&server_addr.sin_zero, 0, sizeof(server_addr.sin_zero)); | |
bind(server_sock, (struct sockaddr*)&server_addr, sizeof(server_addr)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listen(server_sock, 5 /* Max pending connection requests. */); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stuct sockaddr_in client_addr; | |
socklen_t address_len = sizeof(struct sockaddr_in); | |
for (;;) { | |
int client_sock = accept(server_sock, (struct sockaddr*)&client_addr, &address_len); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net" | |
"time" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hCard to h-card Map | |
--- | |
additional-name: p-additional-name | |
adr: [ p-adr, h-adr ] | |
agent: ~ | |
bday: dt-bday | |
category: p-category | |
class: ~ | |
country-name: p-country-name | |
email: u-email |