/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="type"></param> /// <param name="rcvTimeoutInMilliseconds"></param> public Socket(Context context, SocketType type, int rcvTimeoutInMilliseconds = NoTimeout) { if (context == null) { throw new ArgumentNullException("context"); } if (type < SocketType.Pair || type > SocketType.XSub) { throw new ArgumentException("Invalid socket type", "socketType"); } if (rcvTimeoutInMilliseconds < 0) { throw new ArgumentException("Invalid rcvTimeout. Must be greater than zero", "rcvTimeoutInMilliseconds"); } if (context._contextPtr == IntPtr.Zero) { throw new ArgumentException("Specified context has been disposed", "context"); } this._type = type; this.SocketPtr = Native.Socket.zmq_socket(context._contextPtr, (int)type); if (this.SocketPtr == IntPtr.Zero) { Native.ThrowZmqError("Socket creation "); } #if DEBUG _context = context; context.Track(this); #endif if (rcvTimeoutInMilliseconds != NoTimeout) { // Just in case, to avoid memory leaks try { this.SetOption(SocketOpt.RCVTIMEO, rcvTimeoutInMilliseconds); } catch (Exception) { this.InternalDispose(true); throw; } } this.SetOption(SocketOpt.LINGER, 0); }