Create a gist now

Instantly share code, notes, and snippets.

@irl /gif.php
Created Aug 20, 2012

What would you like to do?
Fetching a TCP stream for output over Gopher and HTTP
header('Content-Type: image/gif');
$fp = fsockopen("", 8091, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
while (!feof($fp)) {
echo fgets($fp, 128);
from pygopherd.handlers.pyg import PYGBase
from pygopherd.gopherentry import GopherEntry
from socket import *
class PYGMain(PYGBase):
def canhandlerequest(self):
return 1
def getentry(self):
entry = GopherEntry(self.selector, self.config)
entry.type = 'g'
entry.mimetype = 'image/gif' = 'Room 205 Webcam'
entry.setea('VIEWS', 'image/gif')
return entry
def write(self, wfile):
host = ''
port = 8091
s = socket(AF_INET, SOCK_STREAM)
s.connect((host, port))
while True:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment