{{Quickfixn}} Where is the best placed to catch socket exceptions?

Stan stan.quickfixn at gmail.com
Mon Sep 10 09:48:45 PDT 2012


Hi all, I am porting a server program originally written with QuickFIX C++
.Net wrapper to QuickFIX/n. It worked well for several hours until it
suddenly crashed with this SocketException (extracted from Event Viewer):

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException
Stack:
   at System.Net.Sockets.Socket.Send(Byte[], Int32, Int32,
System.Net.Sockets.SocketFlags)
   at QuickFix.ClientHandlerThread.Send(System.String)
   at QuickFix.Session.Send(System.String)
   at QuickFix.Session.SendRaw(QuickFix.Message, Int32)
   at QuickFix.Session.Send(QuickFix.Message)
   at QuickFix.Session.SendToTarget(QuickFix.Message, QuickFix.SessionID)
   at MyProg.SendData(System.Collections.Generic.List`1<NoMDEntriesGroup>)
   ...

I am guessing the SocketException could be due to various reasons, e.g. TCP
buffer full, client disconnected, etc. That happens on a busy network.

What I would like to know though is how I should handle this issue. Do I
need to put a try-catch around ALL calls to Session.SendToTarget? I've
never did this in the server program when using the .Net wrapper and have
assumed that SendToTarget would always return gracefully with false if it
failed to send. What is the recommended best practice? Advice and
suggestions are most appreciated.

Regards,
S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/attachments/20120911/ca04eb6c/attachment.htm>


More information about the Quickfixn mailing list