C# ZMQ Socket.SetSockOpt SocketOpt.LINGER - What is the valid options?
Question
using (var context = new Context(1))
{
using (Socket socket = context.Socket(SocketType.XREQ))
{
socket.SetSockOpt(SocketOpt.LINGER, 100ul);
socket.Connect("tcp://somewhere:5566");
string content = "test message";
socket.Send(content, Encoding.Unicode);
string message = socket.Recv(Encoding.Unicode);
Console.WriteLine("Received reply: " + message);
}
}
I've tried longs, ulongs and byte arrays and I can not find a value that does not lead to an "illegal argument" exception being thrown.
Solution
As I can see from the clrzmq2 library sources (Socket.cs) there are 4 overloads of the SetSocketOpt() method with long, ulong, byte array or integer parameter. To specify linger period for socket shutdown you shoud use integer parameter. Anyway, I suggest you use the Socket.Linger property to avoid any possible dismissing.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow