diff --git a/solutions/c/01-at4/explanation.md b/solutions/c/01-at4/explanation.md deleted file mode 100644 index 535312b..0000000 --- a/solutions/c/01-at4/explanation.md +++ /dev/null @@ -1,56 +0,0 @@ -The entry point for your HTTP server implementation is in `src/main.c`. - -Study and uncomment the relevant code: - -```c -// Uncomment this block to pass the first stage - -int server_fd, client_addr_len; -struct sockaddr_in client_addr; - -server_fd = socket(AF_INET, SOCK_STREAM, 0); -if (server_fd == -1) { - printf("Socket creation failed: %s...\n", strerror(errno)); - return 1; -} - -// Since the tester restarts your program quite often, setting SO_REUSEADDR -// ensures that we don't run into 'Address already in use' errors -int reuse = 1; -if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) { - printf("SO_REUSEADDR failed: %s \n", strerror(errno)); - return 1; -} - -struct sockaddr_in serv_addr = { .sin_family = AF_INET , - .sin_port = htons(4221), - .sin_addr = { htonl(INADDR_ANY) }, - }; - -if (bind(server_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) != 0) { - printf("Bind failed: %s \n", strerror(errno)); - return 1; -} - -int connection_backlog = 5; -if (listen(server_fd, connection_backlog) != 0) { - printf("Listen failed: %s \n", strerror(errno)); - return 1; -} - -printf("Waiting for a client to connect...\n"); -client_addr_len = sizeof(client_addr); - -accept(server_fd, (struct sockaddr *) &client_addr, &client_addr_len); -printf("Client connected\n"); - -close(server_fd); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/clojure/01-at4/explanation.md b/solutions/clojure/01-at4/explanation.md deleted file mode 100644 index 08be28b..0000000 --- a/solutions/clojure/01-at4/explanation.md +++ /dev/null @@ -1,16 +0,0 @@ -The entry point for your HTTP server implementation is in `src/http_server/core.clj`. - -Study and uncomment the relevant code: - -```clojure -;; Uncomment this block to pass the first stage -(serve) -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/cpp/01-at4/explanation.md b/solutions/cpp/01-at4/explanation.md deleted file mode 100644 index b61d01c..0000000 --- a/solutions/cpp/01-at4/explanation.md +++ /dev/null @@ -1,55 +0,0 @@ -The entry point for your HTTP server implementation is in `src/main.cpp`. - -Study and uncomment the relevant code: - -```cpp -// Uncomment this block to pass the first stage - -int server_fd = socket(AF_INET, SOCK_STREAM, 0); -if (server_fd < 0) { - std::cerr << "Failed to create server socket\n"; - return 1; -} - -// Since the tester restarts your program quite often, setting SO_REUSEADDR -// ensures that we don't run into 'Address already in use' errors -int reuse = 1; -if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) { - std::cerr << "setsockopt failed\n"; - return 1; -} - -struct sockaddr_in server_addr; -server_addr.sin_family = AF_INET; -server_addr.sin_addr.s_addr = INADDR_ANY; -server_addr.sin_port = htons(4221); - -if (bind(server_fd, (struct sockaddr *) &server_addr, sizeof(server_addr)) != 0) { - std::cerr << "Failed to bind to port 4221\n"; - return 1; -} - -int connection_backlog = 5; -if (listen(server_fd, connection_backlog) != 0) { - std::cerr << "listen failed\n"; - return 1; -} - -struct sockaddr_in client_addr; -int client_addr_len = sizeof(client_addr); - -std::cout << "Waiting for a client to connect...\n"; - -accept(server_fd, (struct sockaddr *) &client_addr, (socklen_t *) &client_addr_len); -std::cout << "Client connected\n"; - -close(server_fd); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/csharp/01-at4/explanation.md b/solutions/csharp/01-at4/explanation.md deleted file mode 100644 index 33d8be7..0000000 --- a/solutions/csharp/01-at4/explanation.md +++ /dev/null @@ -1,18 +0,0 @@ -The entry point for your HTTP server implementation is in `src/Server.cs`. - -Study and uncomment the relevant code: - -```csharp -// Uncomment this block to pass the first stage -TcpListener server = new TcpListener(IPAddress.Any, 4221); -server.Start(); -server.AcceptSocket(); // wait for client -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/dart/01-at4/explanation.md b/solutions/dart/01-at4/explanation.md deleted file mode 100644 index 594b43d..0000000 --- a/solutions/dart/01-at4/explanation.md +++ /dev/null @@ -1,21 +0,0 @@ -The entry point for your HTTP server implementation is in `bin/main.dart`. - -Study and uncomment the relevant code: - -```dart -// Uncomment this to pass the first stage - -var serverSocket = await ServerSocket.bind('0.0.0.0', 4221); - -await for (var clientSocket in serverSocket) { - print("Client connected"); -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/elixir/01-at4/explanation.md b/solutions/elixir/01-at4/explanation.md deleted file mode 100644 index 6925f78..0000000 --- a/solutions/elixir/01-at4/explanation.md +++ /dev/null @@ -1,20 +0,0 @@ -The entry point for your HTTP server implementation is in `lib/main.ex`. - -Study and uncomment the relevant code: - -```elixir -# Uncomment this block to pass the first stage - -# Since the tester restarts your program quite often, setting SO_REUSEADDR -# ensures that we don't run into 'Address already in use' errors -{:ok, socket} = :gen_tcp.listen(4221, [:binary, active: false, reuseaddr: true]) -{:ok, _client} = :gen_tcp.accept(socket) -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/gleam/01-at4/explanation.md b/solutions/gleam/01-at4/explanation.md deleted file mode 100644 index 751a8bb..0000000 --- a/solutions/gleam/01-at4/explanation.md +++ /dev/null @@ -1,24 +0,0 @@ -The entry point for your HTTP server implementation is in `src/main.gleam`. - -Study and uncomment the relevant code: - -```gleam -// Uncomment this block to pass the first stage - -let assert Ok(_) = - glisten.handler(fn(_conn) { #(Nil, None) }, fn(_msg, state, _conn) { - io.println("Received message!") - actor.continue(state) - }) - |> glisten.serve(4221) - -process.sleep_forever() -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/go/01-at4/explanation.md b/solutions/go/01-at4/explanation.md deleted file mode 100644 index 1932da0..0000000 --- a/solutions/go/01-at4/explanation.md +++ /dev/null @@ -1,27 +0,0 @@ -The entry point for your HTTP server implementation is in `app/main.go`. - -Study and uncomment the relevant code: - -```go -// Uncomment this block to pass the first stage - -l, err := net.Listen("tcp", "0.0.0.0:4221") -if err != nil { - fmt.Println("Failed to bind to port 4221") - os.Exit(1) -} - -_, err = l.Accept() -if err != nil { - fmt.Println("Error accepting connection: ", err.Error()) - os.Exit(1) -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/haskell/01-at4/explanation.md b/solutions/haskell/01-at4/explanation.md deleted file mode 100644 index 5aeb29b..0000000 --- a/solutions/haskell/01-at4/explanation.md +++ /dev/null @@ -1,34 +0,0 @@ -The entry point for your HTTP server implementation is in `app/Main.hs`. - -Study and uncomment the relevant code: - -```haskell --- Uncomment this block to pass first stage -let host = "127.0.0.1" - port = "4221" - -BC.putStrLn $ "Listening on " <> BC.pack host <> ":" <> BC.pack port - --- Get address information for the given host and port -addrInfo <- getAddrInfo Nothing (Just host) (Just port) - -serverSocket <- socket (addrFamily $ head addrInfo) Stream defaultProtocol -bind serverSocket $ addrAddress $ head addrInfo -listen serverSocket 5 - --- Accept connections and handle them forever -forever $ do - (clientSocket, clientAddr) <- accept serverSocket - BC.putStrLn $ "Accepted connection from " <> BC.pack (show clientAddr) <> "." - -- Handle the clientSocket as needed... - - close clientSocket -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/java/01-at4/explanation.md b/solutions/java/01-at4/explanation.md deleted file mode 100644 index a8d0eba..0000000 --- a/solutions/java/01-at4/explanation.md +++ /dev/null @@ -1,28 +0,0 @@ -The entry point for your HTTP server implementation is in `src/main/java/Main.java`. - -Study and uncomment the relevant code: - -```java -// Uncomment this block to pass the first stage - -try { - ServerSocket serverSocket = new ServerSocket(4221); - - // Since the tester restarts your program quite often, setting SO_REUSEADDR - // ensures that we don't run into 'Address already in use' errors - serverSocket.setReuseAddress(true); - - serverSocket.accept(); // Wait for connection from client. - System.out.println("accepted new connection"); -} catch (IOException e) { - System.out.println("IOException: " + e.getMessage()); -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/javascript/01-at4/explanation.md b/solutions/javascript/01-at4/explanation.md deleted file mode 100644 index 9de6f7c..0000000 --- a/solutions/javascript/01-at4/explanation.md +++ /dev/null @@ -1,22 +0,0 @@ -The entry point for your HTTP server implementation is in `app/main.js`. - -Study and uncomment the relevant code: - -```javascript -// Uncomment this to pass the first stage -const server = net.createServer((socket) => { - socket.on("close", () => { - socket.end(); - }); -}); - -server.listen(4221, "localhost"); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/kotlin/01-at4/explanation.md b/solutions/kotlin/01-at4/explanation.md deleted file mode 100644 index 433af3f..0000000 --- a/solutions/kotlin/01-at4/explanation.md +++ /dev/null @@ -1,23 +0,0 @@ -The entry point for your HTTP server implementation is in `app/src/main/kotlin/App.kt`. - -Study and uncomment the relevant code: - -```kotlin -// Uncomment this block to pass the first stage -var serverSocket = ServerSocket(4221) - -// Since the tester restarts your program quite often, setting SO_REUSEADDR -// ensures that we don't run into 'Address already in use' errors -serverSocket.reuseAddress = true - -serverSocket.accept() // Wait for connection from client. -println("accepted new connection") -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/python/01-at4/explanation.md b/solutions/python/01-at4/explanation.md deleted file mode 100644 index e1bb2d9..0000000 --- a/solutions/python/01-at4/explanation.md +++ /dev/null @@ -1,18 +0,0 @@ -The entry point for your HTTP server implementation is in `app/main.py`. - -Study and uncomment the relevant code: - -```python -# Uncomment this to pass the first stage - -server_socket = socket.create_server(("localhost", 4221), reuse_port=True) -server_socket.accept() # wait for client -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/ruby/01-at4/explanation.md b/solutions/ruby/01-at4/explanation.md deleted file mode 100644 index 3cb549e..0000000 --- a/solutions/ruby/01-at4/explanation.md +++ /dev/null @@ -1,18 +0,0 @@ -The entry point for your HTTP server implementation is in `app/server.rb`. - -Study and uncomment the relevant code: - -```ruby -# Uncomment this to pass the first stage - -server = TCPServer.new("localhost", 4221) -client_socket, client_address = server.accept -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/rust/01-at4/explanation.md b/solutions/rust/01-at4/explanation.md deleted file mode 100644 index b56d9ef..0000000 --- a/solutions/rust/01-at4/explanation.md +++ /dev/null @@ -1,28 +0,0 @@ -The entry point for your HTTP server implementation is in `src/main.rs`. - -Study and uncomment the relevant code: - -```rust -// Uncomment this block to pass the first stage - -let listener = TcpListener::bind("127.0.0.1:4221").unwrap(); - -for stream in listener.incoming() { - match stream { - Ok(_stream) => { - println!("accepted new connection"); - } - Err(e) => { - println!("error: {}", e); - } - } -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/typescript/01-at4/explanation.md b/solutions/typescript/01-at4/explanation.md deleted file mode 100644 index 200d412..0000000 --- a/solutions/typescript/01-at4/explanation.md +++ /dev/null @@ -1,22 +0,0 @@ -The entry point for your HTTP server implementation is in `app/main.ts`. - -Study and uncomment the relevant code: - -```typescript -// Uncomment this to pass the first stage -const server = net.createServer((socket) => { - socket.on("close", () => { - socket.end(); - }); -}); - -server.listen(4221, "localhost"); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/zig/01-at4/explanation.md b/solutions/zig/01-at4/explanation.md deleted file mode 100644 index 66477e4..0000000 --- a/solutions/zig/01-at4/explanation.md +++ /dev/null @@ -1,23 +0,0 @@ -The entry point for your HTTP server implementation is in `src/main.zig`. - -Study and uncomment the relevant code: - -```zig -// Uncomment this block to pass the first stage -const address = try net.Address.resolveIp("127.0.0.1", 4221); -var listener = try address.listen(.{ - .reuse_address = true, -}); -defer listener.deinit(); - -_ = try listener.accept(); -std.debug.print("client connected!", .{}); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -```