public bool Init(string network) { m_address = new PgmAddress(network); m_pgmSocket = new PgmSocket(m_options, PgmSocketType.Listener, m_address); m_pgmSocket.Init(); m_handle = m_pgmSocket.FD; try { m_handle.Bind(m_address.Address); m_pgmSocket.InitOptions(); m_handle.Listen(m_options.Backlog); } catch (SocketException ex) { Close(); return false; } m_socket.EventListening(m_address.ToString(), m_handle); return true; }
public PgmSession(PgmSocket pgmSocket, Options options) { m_handle = pgmSocket.FD; m_pgmSocket = pgmSocket; m_options = options; data = new byte[Config.PgmMaxTPDU]; }
public void InEvent() { Socket fd; try { fd = Accept(); } catch (Exception) { // If connection was reset by the peer in the meantime, just ignore it. // TODO: Handle specific errors like ENFILE/EMFILE etc. //ZError.exc (e); m_socket.EventAcceptFailed(m_address.ToString(), ZError.ErrorNumber); return; } PgmSocket pgmSocket = new PgmSocket(m_options, PgmSocketType.Receiver, m_address); pgmSocket.Init(fd); PgmSession pgmSession = new PgmSession(pgmSocket, m_options); IOThread ioThread = ChooseIOThread(m_options.Affinity); SessionBase session = SessionBase.Create(ioThread, false, m_socket, m_options, new Address(m_handle.LocalEndPoint)); session.IncSeqnum(); LaunchChild(session); SendAttach(session, pgmSession, false); m_socket.EventAccepted(m_address.ToString(), fd); }
public void Init(PgmAddress pgmAddress) { m_pgmSocket = new PgmSocket(m_options, PgmSocketType.Publisher, m_addr.Resolved as PgmAddress); m_pgmSocket.Init(); m_socket = m_pgmSocket.FD; IPEndPoint localEndpoint = new IPEndPoint(IPAddress.Any, 0); m_socket.Bind(localEndpoint); m_pgmSocket.InitOptions(); m_socket.Connect(pgmAddress.Address); m_socket.Blocking = false; m_outBufferSize = Config.PgmMaxTPDU; m_outBuffer = new ByteArraySegment(new byte[m_outBufferSize]); }
public void InEvent() { Socket fd; try { fd = Accept(); } catch (SocketException ex) { m_socket.EventAcceptFailed(m_address.ToString(), ErrorHelper.SocketErrorToErrorCode(ex.SocketErrorCode)); return; } catch (NetMQException ex) { // If connection was reset by the peer in the meantime, just ignore it. // TODO: Handle specific errors like ENFILE/EMFILE etc. //ZError.exc (e); m_socket.EventAcceptFailed(m_address.ToString(), ex.ErrorCode); return; } PgmSocket pgmSocket = new PgmSocket(m_options, PgmSocketType.Receiver, m_address); pgmSocket.Init(fd); PgmSession pgmSession = new PgmSession(pgmSocket, m_options); IOThread ioThread = ChooseIOThread(m_options.Affinity); SessionBase session = SessionBase.Create(ioThread, false, m_socket, m_options, new Address(m_handle.LocalEndPoint)); session.IncSeqnum(); LaunchChild(session); SendAttach(session, pgmSession, false); m_socket.EventAccepted(m_address.ToString(), fd); }
public void Init(string network) { m_address = new PgmAddress(network); m_pgmSocket = new PgmSocket(m_options, PgmSocketType.Listener, m_address); m_pgmSocket.Init(); m_handle = m_pgmSocket.FD; try { m_handle.Bind(m_address.Address); m_pgmSocket.InitOptions(); m_handle.Listen(m_options.Backlog); } catch (SocketException ex) { Close(); throw NetMQException.Create(ex); } m_socket.EventListening(m_address.ToString(), m_handle); }