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

Stan stan.quickfixn at gmail.com
Mon Sep 10 10:19:15 PDT 2012


Looking through the source code, I note that BUF_SIZE for
SocketInitiatorThread.cs and SocketReader.cs are 512 bytes and 4096 bytes.
I wonder if these are too small for some TCP applications with low
bandwidth and high latency? (That could be the cause of my SocketException.)

Perhaps there should be some configuration file option for these buffer
sizes? And also TcpClient.SendBufferSize and TcpClient.ReceiveBufferSize.

Regards,
S

On Tue, Sep 11, 2012 at 12:48 AM, Stan <stan.quickfixn at gmail.com> wrote:

> 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
>
> _______________________________________________
> Quickfixn mailing list
> Quickfixn at lists.quickfixn.com
> http://lists.quickfixn.com/listinfo.cgi/quickfixn-quickfixn.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/attachments/20120911/94a7135b/attachment-0002.htm>


More information about the Quickfixn mailing list