Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const net = require('net');
- const http = require('http');
- http.createServer((req, res) => {
- // console.log(req)
- console.log('REQ, RES')
- res.end('RESPONSE OK')
- }).listen(1337)
- const socket = net.createConnection({ port: 1337 }, () => {
- console.log('Connected')
- // Wrong
- socket.end('GET / http/1.1\r\nConnection: close\r\n\r\n')
- // Correct
- // socket.end('GET / HTTP/1.1\r\nConnection: close\r\n\r\n')
- })
- socket.on('data', (data) => {
- console.log('DATA')
- console.log(data.toString())
- })
- socket.on('end', () => {
- console.log('END')
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement