/// <inheritdoc/> protected override IEnumerable <EndPoint> BindInternal(IEnumerable <EndPoint> localEndPoints) { HashSet <EndPoint> newLocalEPs = new HashSet <EndPoint>(); lock (BoundHandlers) { foreach (EndPoint ep in localEndPoints) { LoopbackEndPoint localEP = ep as LoopbackEndPoint; if (localEP == null || localEP.Port == 0) { localEP = null; for (Int32 i = 10000; i < Int32.MaxValue; i++) { LoopbackEndPoint newLocalEP = new LoopbackEndPoint(i); if (!BoundHandlers.ContainsKey(newLocalEP) && !newLocalEPs.Contains(newLocalEP)) { localEP = newLocalEP; break; } } if (localEP == null) { throw new IOException("No port available."); } } else if (localEP.Port < 0) { throw new IOException("Bind port number must be 0 or above."); } else if (BoundHandlers.ContainsKey(localEP)) { throw new IOException("Address already bound: " + localEP); } newLocalEPs.Add(localEP); } foreach (LoopbackEndPoint localEP in newLocalEPs) { if (BoundHandlers.ContainsKey(localEP)) { foreach (LoopbackEndPoint ep in newLocalEPs) { BoundHandlers.Remove(ep); } throw new IOException("Duplicate local address: " + localEP); } else { BoundHandlers[localEP] = new LoopbackPipe(this, localEP, Handler); } } } _idleStatusChecker.Start(); return(newLocalEPs); }
/// <inheritdoc/> protected override IEnumerable<EndPoint> BindInternal(IEnumerable<EndPoint> localEndPoints) { HashSet<EndPoint> newLocalEPs = new HashSet<EndPoint>(); lock (BoundHandlers) { foreach (EndPoint ep in localEndPoints) { LoopbackEndPoint localEP = ep as LoopbackEndPoint; if (localEP == null || localEP.Port == 0) { localEP = null; for (Int32 i = 10000; i < Int32.MaxValue; i++) { LoopbackEndPoint newLocalEP = new LoopbackEndPoint(i); if (!BoundHandlers.ContainsKey(newLocalEP) && !newLocalEPs.Contains(newLocalEP)) { localEP = newLocalEP; break; } } if (localEP == null) throw new IOException("No port available."); } else if (localEP.Port < 0) { throw new IOException("Bind port number must be 0 or above."); } else if (BoundHandlers.ContainsKey(localEP)) { throw new IOException("Address already bound: " + localEP); } newLocalEPs.Add(localEP); } foreach (LoopbackEndPoint localEP in newLocalEPs) { if (BoundHandlers.ContainsKey(localEP)) { foreach (LoopbackEndPoint ep in newLocalEPs) { BoundHandlers.Remove(ep); } throw new IOException("Duplicate local address: " + localEP); } else { BoundHandlers[localEP] = new LoopbackPipe(this, localEP, Handler); } } } _idleStatusChecker.Start(); return newLocalEPs; }
/// <summary> /// Constructor for server-side session. /// </summary> public LoopbackSession(LoopbackSession remoteSession, LoopbackPipe entry) : base(entry.Acceptor) { Config = new DefaultLoopbackSessionConfig(); _lock = remoteSession._lock; _localEP = remoteSession._remoteEP; _remoteEP = remoteSession._localEP; _filterChain = new LoopbackFilterChain(this); _remoteSession = remoteSession; _receivedMessageQueue = new ConcurrentQueue<Object>(); }
/// <summary> /// Constructor for server-side session. /// </summary> public LoopbackSession(LoopbackSession remoteSession, LoopbackPipe entry) : base(entry.Acceptor) { Config = new DefaultLoopbackSessionConfig(); _lock = remoteSession._lock; _localEP = remoteSession._remoteEP; _remoteEP = remoteSession._localEP; _filterChain = new LoopbackFilterChain(this); _remoteSession = remoteSession; _receivedMessageQueue = new ConcurrentQueue <Object>(); }
/// <summary> /// Constructor for client-side session. /// </summary> public LoopbackSession(IoService service, LoopbackEndPoint localEP, IoHandler handler, LoopbackPipe remoteEntry) : base(service) { Config = new DefaultLoopbackSessionConfig(); _lock = new Byte[0]; _localEP = localEP; _remoteEP = remoteEntry.Endpoint; _filterChain = new LoopbackFilterChain(this); _receivedMessageQueue = new ConcurrentQueue<Object>(); _remoteSession = new LoopbackSession(this, remoteEntry); }
/// <summary> /// Constructor for client-side session. /// </summary> public LoopbackSession(IoService service, LoopbackEndPoint localEP, IoHandler handler, LoopbackPipe remoteEntry) : base(service) { Config = new DefaultLoopbackSessionConfig(); _lock = new Byte[0]; _localEP = localEP; _remoteEP = remoteEntry.Endpoint; _filterChain = new LoopbackFilterChain(this); _receivedMessageQueue = new ConcurrentQueue <Object>(); _remoteSession = new LoopbackSession(this, remoteEntry); }