How about:
# Copyright (c) 2001-2004 Twisted Matrix Laboratories. # See LICENSE for details. """ An example client. Run simpleserv.py first before running this. """ from twisted.internet import reactor, protocol # a client protocol class EchoClient(protocol.Protocol): """Once connected, send a message, then print the result.""" def connectionMade(self): self.transport.write("hello, world!") def dataReceived(self, data): "As soon as any data is received, write it back." print "Server said:", data self.transport.loseConnection() def connectionLost(self, reason): print "connection lost" class EchoFactory(protocol.ClientFactory): protocol = EchoClient def clientConnectionFailed(self, connector, reason): print "Connection failed - goodbye!" reactor.stop() def clientConnectionLost(self, connector, reason): print "Connection lost - goodbye!" reactor.stop() # this connects the protocol to a server runing on port 8000 def main(): f = EchoFactory() reactor.connectTCP("localhost", 8000, f) reactor.run() # this only runs if the module was *not* imported if __name__ == '__main__': main() ------------------------- # Copyright (c) 2001-2004 Twisted Matrix Laboratories. # See LICENSE for details. from twisted.internet import reactor, protocol class Echo(protocol.Protocol): """This is just about the simplest possible protocol""" def dataReceived(self, data): "As soon as any data is received, write it back." self.transport.write(data) def main(): """This runs the protocol on port 8000""" factory = protocol.ServerFactory() factory.protocol = Echo reactor.listenTCP(8000,factory) reactor.run() # this only runs if the module was *not* imported if __name__ == '__main__': main() ----- Mark On Wed, Feb 10, 2010 at 1:54 PM, Darren Govoni <dar...@ontrenet.com> wrote: > Hey Mark, > Yeah, that's what I want, but in the 'twisted' way. I can write socket > servers, etc. But didn't notice a good example of how to do this in Twisted > (sparing me the socket programming), until I found this old message[1] with > the classes I think might work. > > [1] > http://twistedmatrix.com/pipermail/twisted-python/2007-July/015738.html > > Darren > > On Wed, 2010-02-10 at 13:36 -0500, Mark Bailey wrote: > > Hi Darren: > > Why not use TCP? You can send the length of the file at the beginning so > you know how many bytes to listen for. > TCP guarantees delivery and ordering. > > Mark > > On Wed, Feb 10, 2010 at 12:22 PM, Darren Govoni <dar...@ontrenet.com> > wrote: > > Hi, > Is there an existing protocol that can provide the following? > > - Accept stream binary data FROM a client (e.g. very large file transfer) > - Receive data IN ORDER (i.e. stream. not out of order random packets) > > I want to stream FROM a client to the protocol server and have the > server process the stream bytes incrementally so it doesn't have > to store or write the entire data stream (too large). > > I looked at FileTransferServer and Client, but I'm not sure it provides > what I need. > > Any tips appreciated! > Darren > > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > > _______________________________________________ > Twisted-Python mailing > listtwisted-pyt...@twistedmatrix.comhttp://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > >
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python