Interactive socket connection

Rayed Al-Rashed rayed at
Sat Jun 1 05:10:51 EDT 2002


I am trying to build POP3 proxy, I want it to run from "inetd" so it should 
communicate with the user using regular stdin, stdout.
I built a small code that should run as general proxy for any protocol, but 
I faced the following problem, it doesn't show any output from the server 
until I pass it a command, for example:

user rayed
+OK POP3 server ready
pass mypass
+OK User name accepted, password please
rert 1
-ERR Bad login
-ERR Unknown AUTHORIZATION state command

+OK Sayonara

Any ideas what the problem is?
Thanks in advance,

- rayed

This the proxy code
# POP3 proxy

import sys
import string
import socket
import asyncore
import select

class proxy (asyncore.dispatcher):
         def __init__(self, server, port):
                 self.connect ((server, port))

         def handle_connect (self):

         def handle_read (self):
                 buf = self.recv(8012)
                 sys.stdout.write( buf )

         def handle_write (self):
                 buf = sys.stdin.readline()

         def handle_close (self):
                 print "Closed"

if __name__ == '__main__':
         p = proxy("", 110)

More information about the Python-list mailing list