This file contains 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
const express = require('express') | |
const app = express() | |
const port = 3333 | |
app.get('/', (req, res) => { | |
res.send('Hello World!') | |
}) | |
app.listen(port, () => { | |
console.log(`Example app listening on port ${port}`) |
This file contains 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
var net = require('net'); | |
var server = net.createServer(function(socket) { | |
socket.write('Hello TCP!'); | |
socket.pipe(socket); | |
// for testing purposes we handle client side errors | |
socket.on('error', function(err) { | |
if (err.code === 'ECONNRESET') { | |
console.error('Client closed connection'); |
This file contains 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
import socket | |
host = "localhost" | |
port = 4444 | |
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
client.connect((host,port)) | |
client.send(b"") | |
response = client.recv(4096) | |
print(response) |
This file contains 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
import multiprocessing | |
import time | |
import socket | |
def process_1(): | |
# this demonstrates a third party lib | |
print("Process 1 is running") | |
while True: | |
time.sleep(10) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.