Fetching a TCP stream for output over Gopher and HTTP
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
| <?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); | |
| } |
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
| 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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment