Skip to content

Instantly share code, notes, and snippets.

@acg
acg / tcplisten
Created December 5, 2012 01:22
Factoring out the listen(2) half of djb's tcpserver.
#!/usr/bin/env python
import sys
import os
import socket
port = sys.argv.pop(0)
host = sys.argv.pop(0)
port = int(sys.argv.pop(0))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
$ grep -iHn poop netcat.c
netcat.c:94:struct host_poop {
netcat.c:99:#define HINF struct host_poop
netcat.c:101:struct port_poop {
netcat.c:106:#define PINF struct port_poop
netcat.c:143:HINF ** gates = NULL; /* LSRR hop hostpoop */
netcat.c:149:PINF * portpoop = NULL; /* for getportpoop / getservby* */
netcat.c:299: cross-check the host_poop we have so far against new gethostby*() info,
netcat.c:303:int comparehosts (poop, hp)