[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mojonation-devel
Subject:    [Mojonation-devel] Broken pipes
From:       Peter Soetens (KaLTaN) <peter.soetens () advalvas ! be>
Date:       2001-07-04 13:37:37
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I'm currently working on a Socket implementation in C++.  We had to insert 
special code to resume reading/writing when a "broken pipe" occured on the 
socket.  
I took a quick look at the (obscure :-) mojonation socket code and didn't see 
directly an equivalent system.  That is maybe because Python handles sockets 
differently, anyway, it slipped my mind that maybe this was the cause of the 
"TCP connection refused" we get after xx seconds.

Normally a read/write is done in once, but when it failes (nTemp < nCount), 
it restarts writing the unwritten data to the socket.

LONG CSocket::MyWrite ( const void *cvBuf, LONG nCount )
    {
    int nI,nTemp,nTimeout;
    for ( nI = 0, nTimeout = 0; nI < nCount; )
	  {
	  nTimeout++;
	  if ( nTimeout > CONNECTION_TIMEOUT )
		{
		return -1;
		} // if ( nTimeout > CONNECTION_TIMEOUT )

	  nTemp = write ( m_nSocket, (void*)( ( (char*) cvBuf ) + nI ),nCount - nI );
	  nI += nTemp;
	  if ( nTemp < 0 )
		{
		perror ("write: ");
		return nTemp;
		} // if ( nTemp < 0 )
	  } // for ( nI = 0, nTimeout = 0; nI < nCount; )
    return nI;
    };

Just a lucky guess.

greetz, K.
- -- 
- -------------------------------------------------
   Visit the 3Dsia Project http://www.3Dsia.org
 A Virtual Reality Environment without limits
           - now using RMC and ODB -
http://morgner.com/odb/   http://morgner.com/rmc/
- -------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7QxwoKfGwAkGiwccRAsPpAJ99pUsRDHd/nzg+6FsJNRq+oPaP3QCeLAu2
N/KDvkbKxt25nYlGrpNh1D8=
=YOlp
-----END PGP SIGNATURE-----

_______________________________________________
Mojonation-devel mailing list
Mojonation-devel@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mojonation-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic