https://github.com/hackvan/tcp-protocol
Making an HTTP server with Node and Ruby in the TCP layer.
https://github.com/hackvan/tcp-protocol
Last synced: 10 months ago
JSON representation
Making an HTTP server with Node and Ruby in the TCP layer.
- Host: GitHub
- URL: https://github.com/hackvan/tcp-protocol
- Owner: hackvan
- Created: 2020-05-29T23:02:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-29T23:44:51.000Z (over 5 years ago)
- Last Synced: 2025-01-05T17:13:23.945Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HTTP basic examples inside the TCP layer
These are examples with Node and Ruby for try to make a (very) basic HTTP server to return responses for the HTTP/1.1 protocol version.
## Requirements:
```bash
$ node -v
v10.16.0
$ ruby -v
ruby 2.6.3p62
```
## Run the Servers:
### Javascript
```bash
$ node node/index.js
```
### Ruby
```bash
$ ruby ruby/server.rb
```
## Try with:
- Web Browser
[http://localhost:3000](http://localhost:3000)
- Telnet CLI
```bash
$ telnet localhost 3000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
```
Type in: `GET / HTTP/1.1`
Return:
```bash
HTTP/1.1 200 OK
Hola Mundo
Connection closed by foreign host.
```
## Resources:
1. [Make It Real - Tutorial](https://www.youtube.com/watch?v=rcrb-i86ohE)
1. [Ruby Docs - Sockets](https://ruby-doc.org/stdlib-2.5.3/libdoc/socket/rdoc/TCPServer.html)