Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fyx99
fyx99 / python-tcp-reroute.py
Created April 15, 2023 22:31
TCP Rerouting using Pythons socket module
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)
@fyx99
fyx99 / tcp-client.py
Created April 13, 2023 14:41
Python TCP Client
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)
@fyx99
fyx99 / app-tcp.js
Created April 12, 2023 19:45
Node.Js Example TCP Server
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');
@fyx99
fyx99 / app-http.js
Last active April 12, 2023 19:45
Node.Js Example HTTP Server
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}`)