JP wrote:

> There are no such known limits.  I might even go as far to say that there
> are no such limits, if I were feeling daring. :)  Do you have a short
> program which demonstrates this behavior that you can share? 
> Perhaps after looking at that someone can suggest the cause of the disconnects.

After looking into it some more myself i realised an uncaught exception was dropping the connection but the after cutting my test code back to minimal functionality the inconsistency with received data was still there. The last 4KB of the data was received and the first 14KB discarded somewhere!

I have created a minimal example from my initial test code. Start the simpleserver with twistd.py -y simpleserver.py and just run the simpleclient.py the builder.dat file is just a nonsense file that is about 18KB in size. Testing on my machine produced a received.dat file which was 4KB in size. I am currently using Python 2.3.3 and Twisted 1.3.0. The code is as follows (and is also attached for convenient running):

### ------------ simpleclient.py ---------------------------------

from twisted.internet.protocol import Protocol
import twisted.internet.error
from simpleprotos import SimpleClientFactory
factory = SimpleClientFactory()

# open a large nonsense file to send (18KB)
f = file('builder.dat')
data = f.read()
print len(data)
f.close()

from twisted.internet import reactor
reactor.connectTCP('127.0.0.1', 10000, factory)
reactor.callLater(1.0, factory.sendMessage, data)
reactor.run()

### ------------- end ---------------------------------------------

### ------------ simpleserver.py ----------------------------------

from twisted.application import internet # services that run TCP/SSL/etc.
from twisted.application import service
from simpleprotos import ServerDataConnection, SimpleFactory

def makeService():
    factory = SimpleFactory() # here we create a ConnectionManager
    return internet.TCPServer(10000, factory)

application = service.Application("Connection Manager")
sc = service.IServiceCollection(application)
sc.addService(makeService())

### ------------- end ---------------------------------------------

### ------------ simpleprotos.py ----------------------------------

from twisted.internet.protocol import ClientFactory, Factory, Protocol

class SimpleClientFactory(ClientFactory):
    def buildProtocol(self, addr):
        self.p = ClientDataConnection()
        self.p.factory = self
        return self.p
   
    def sendMessage(self, data):
        if hasattr(self, 'p'):
            self.p.sendData(data)

class SimpleFactory(Factory):
    def buildProtocol(self, addr):
        self.p = ServerDataConnection()
        self.p.factory = self
        return self.p

class ServerDataConnection(Protocol):
    def closeConnection(self):
        self.transport.loseConnection()
   
    def dataReceived(self, data):
        f = file('received.dat', 'w')
        f.write(data)
        f.close()


class ClientDataConnection(Protocol):
    def closeConnection(self):
        self.transport.loseConnection()
   
    def sendData(self, data):
        self.transport.write(data)

### ------------- end ---------------------------------------------

Regards,

Grant McDonald

 

Important notice: This message is intended for the individual(s) and entity(s) addressed. The information contained in this transmission and any attached, may be confidential and may also be the subject of legal privilege, public interest immunity or legal professional privilege. Any review, retransmission, dissemination or other use of, taking of any action in reliance upon this information by person or entities other than the recipient is prohibited and requires authorization from the sender. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person) you may not copy or deliver this message to anyone. In such cases you should destroy this message and kindly notify the sender by reply email.

WARNING: Although Infocomp has taken reasonable precautions so that no viruses are present in this e-mail, the company cannot accept responsibility for any loss or damage arising from the use of e-mail attachments.