public int Forward(IntPtr destinationHandle) { if (_msg.Init() == -1) { return(-1); } int receiveMore; int bytesSent; do { if (LibZmq.zmq_msg_recv(_msg, SocketHandle, 0) == -1) { return(-1); } if (GetReceiveMore(out receiveMore) == -1) { return(-1); } if ((bytesSent = LibZmq.zmq_msg_send(_msg, destinationHandle, receiveMore == 1 ? (int)SocketFlags.SendMore : 0)) == -1) { return(-1); } }while (receiveMore == 1); if (_msg.Close() == -1) { return(-1); } return(bytesSent); }
public int Close() { int rc = LibZmq.zmq_msg_close(_ptr); _initialized = false; return(rc); }
public int Init(int size) { int rc = LibZmq.zmq_msg_init_size(_ptr, size); _initialized = true; return(rc); }
public int Init() { int rc = LibZmq.zmq_msg_init(_ptr); _initialized = true; return(rc); }
public static int IfInterrupted <T1, T2, T3>(Func <T1, T2, T3, int> operation, T1 arg1, T2 arg2, T3 arg3) { int rc; do { rc = operation(arg1, arg2, arg3); }while (rc == -1 && LibZmq.zmq_errno() == ErrorCode.EINTR); return(rc); }
public int Close() { // Allow Close to be called repeatedly without failure if (SocketHandle == IntPtr.Zero) { return(0); } int rc = LibZmq.zmq_close(SocketHandle); SocketHandle = IntPtr.Zero; return(rc); }
public static ErrorDetails GetLastError() { int errorCode = GetErrorCode(); if (KnownErrors.ContainsKey(errorCode)) { return(KnownErrors[errorCode]); } string message = Marshal.PtrToStringAnsi(LibZmq.zmq_strerror(errorCode)); var errorDetails = new ErrorDetails(errorCode, message); KnownErrors[errorCode] = errorDetails; return(errorDetails); }
public void Terminate() { if (ContextHandle == IntPtr.Zero) { return; } while (LibZmq.zmq_ctx_destroy(ContextHandle) != 0) { int errorCode = ErrorProxy.GetErrorCode(); // If zmq_ctx_destroy fails, valid return codes are EFAULT or EINTR. If EINTR is set, termination // was interrupted by a signal and may be safely retried. if (errorCode == ErrorCode.EFAULT) { // This indicates an invalid context was passed in. There's nothing we can do about it here. // It's arguably not a fatal error, so throwing an exception would be bad seeing as this may // run inside a finalizer. break; } } ContextHandle = IntPtr.Zero; }
public IntPtr CreateSocket(int socketType) { return(LibZmq.zmq_socket(ContextHandle, socketType)); }
public int Initialize() { ContextHandle = LibZmq.zmq_ctx_new(); return(ContextHandle == IntPtr.Zero ? -1 : 0); }
public int Monitor(string endpoint, int events) { return(LibZmq.zmq_socket_monitor(SocketHandle, endpoint, events)); }
public int Disconnect(string endpoint) { return(LibZmq.zmq_disconnect(SocketHandle, endpoint)); }
public IntPtr Data() { return(LibZmq.zmq_msg_data(_ptr)); }
public int Size() { return(LibZmq.zmq_msg_size(_ptr)); }
public int GetContextOption(int option) { return(LibZmq.zmq_ctx_get(ContextHandle, option)); }
public int Unbind(string endpoint) { return(LibZmq.zmq_unbind(SocketHandle, endpoint)); }
public int SetContextOption(int option, int value) { return(LibZmq.zmq_ctx_set(ContextHandle, option, value)); }
public static int GetErrorCode() { return(LibZmq.zmq_errno()); }