You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ai...@apache.org on 2008/05/07 15:46:52 UTC
svn commit: r654104 -
/incubator/qpid/branches/M2.x/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
Author: aidan
Date: Wed May 7 06:46:51 2008
New Revision: 654104
URL: http://svn.apache.org/viewvc?rev=654104&view=rev
Log:
QPID-952 should have been part of previous commit
Modified:
incubator/qpid/branches/M2.x/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
Modified: incubator/qpid/branches/M2.x/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs?rev=654104&r1=654103&r2=654104&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs (original)
+++ incubator/qpid/branches/M2.x/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs Wed May 7 06:46:51 2008
@@ -53,6 +53,11 @@
{
_socket = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ /// For future note TCP Set NoDelay options may help, though with the blocking io not sure
+ /// The Don't linger may help with detecting disconnect but that hasn't been the case in testing.
+ /// _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.NoDelay, 0);
+ /// _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.DontLinger, 0);
+
IPHostEntry ipHostInfo = Dns.Resolve(_host); // Note: don't fix this warning. We do this for .NET 1.1 compatibility.
IPAddress ipAddress = ipHostInfo.AddressList[0];
@@ -77,6 +82,8 @@
{
_log.Error("Write caused exception", e);
_protocolListener.OnException(e);
+ // We should provide the error synchronously as we are doing blocking io.
+ throw e;
}
}
@@ -87,6 +94,17 @@
int numOctets = _networkStream.Read(bytes, 0, bytes.Length);
+ /// Read only returns 0 if the socket has been gracefully shutdown.
+ /// http://msdn2.microsoft.com/en-us/library/system.net.sockets.networkstream.read(VS.71).aspx
+ /// We can use this to block Send so the next Read will force an exception forcing failover.
+ /// Otherwise we need to wait ~20 seconds for the NetworkStream/Socket code to realise that
+ /// the socket has been closed.
+ if (numOctets == 0)
+ {
+ _socket.Shutdown(SocketShutdown.Send);
+ _socket.Close();
+ }
+
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.limit(numOctets);