The sockserv Python module allows one to easily create SMTP/NNTP/POP-like command/response socket servers very easily. Take the following example:
import sockserv, os, string
class uptimed(sockserv.sockserv): helpinfo_QUIT = ( '200- QUIT', 'Terminate the connection.' ) def do_QUIT(self, client, cmd, args): client.send('Bye now!', nl = 1) return(1)
helpinfo_UPTIME = ( '200- UPTIME', 'Display hosts uptime information.' ) def do_UPTIME(self, client, cmd, args): uptime = string.strip(os.popen('uptime', 'r').readlines()) client.send(str(uptime), nl = 1)
s = uptimed(5000) s.mainloop()
The standard socket library module is a fairly slim layer on top of standard Unix sockets. As you can see, this is a much higher-level abstraction. It's been in use internally for around a year now, and has been used as the base for numerous internal projects including SMTP servers and proxies, POP and other similar protocols.
For more information see http://www.tummy.com/sockserv/
Sean == Why would I want to be a Doctor, when I could be a MASTER? Sean Reifschneider, Inimitably Superfluous firstname.lastname@example.org URL: http://www.tummy.com/xvscan HP-UX/Linux/FreeBSD/BSDOS scanning software.
<P><A HREF="http://www.tummy.com/sockserv/">sockserv</A> - allows one to easily create SMTP/NNTP/POP-like command/response socket servers very easily. (23-Nov-99)