Developing a network protocol with Python

Laszlo Zsolt Nagy gandalf at designaproduct.biz
Mon Dec 12 06:21:00 EST 2005


  Hello,

I would like to develop a new network protocol, where the server and the 
clients are Python programs.
I think to be effective, I need to use TCP_NODELAY, and manually 
buffered transfers.
I would like to create a general messaging object that has methods like

sendinteger
recvinteger
sendstring
recvstring

To be more secure, I think I can use this loads function to transfer 
more elaborate python stuctures:

def loads(s):
    """Loads an object from a string.
   
    @param s: The string to load the object from.
    @return: The object loaded from the string. This function will not 
unpickle globals and instances.
    """
    f = cStringIO.StringIO(s)
    p = cPickle.Unpickler(f)
    p.find_global = None
    return p.load()

Am I on the right way to develop a new protocol?
Are there any common mistakes that programmers do?
Is there a howto where I can read more about this?

Thanks

   Les





More information about the Python-list mailing list