public
Last active

Fetching a TCP stream for output over Gopher and HTTP

  • Download Gist
gif.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php
 
header('Content-Type: image/gif');
 
$fp = fsockopen("marang.room205.org", 8091, $errno, $errstr, 30);
 
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
gif.pyg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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'
entry.name = 'Room 205 Webcam'
entry.setea('VIEWS', 'image/gif')
entry.setgopherpsupport(1)
return entry
def write(self, wfile):
host = 'marang.room205.org'
port = 8091
 
s = socket(AF_INET, SOCK_STREAM)
 
s.connect((host, port))
 
while True:
wfile.write(s.recv(1024))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.