public ServerSocket() { data = new byte[102400]; //得到本机IP,设置TCP端口号 ipep = new IPEndPoint(IPAddress.Any, 6000); newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //绑定网络地址 newsock.Bind(ipep); //得到客户机IP sender = new IPEndPoint(IPAddress.Any, 0); Remote = (EndPoint)(sender); ////客户机连接成功后,发送欢迎信息 //string welcome = "Welcome ! "; ////字符串与字节数组相互转换 //data = Encoding.ASCII.GetBytes(welcome); ////发送信息 //newsock.SendTo(data, data.Length, SocketFlags.None, Remote); texture = new Texture2D(960, 720); thread = new Thread(start); thread.IsBackground = true; thread.Start(); Debug.Log("Thread start"); }
public Arc(EndPoint Start, EndPoint End, double Thickness, Color Color) { this._Start = Start; this._End = End; this._Thickness = Thickness; this._Color = Color; }
public Task ConnectTaskAsync(EndPoint endPoint) { return Task.Factory.FromAsync( (cb, st) => BeginConnect(endPoint, cb, st), ias => EndConnect(ias), null); }
public UDPClient(string serverIP) { //Paquete sendData = new Paquete (); //sendData.id = 0; //sendData.identificadorPaquete = Paquete.Identificador.conectar; entrantPackagesCounter = 0; sendingPackagesCounter = 0; //Creamos conexion this.clientSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Inicializamos IP del servidor try{ IPAddress ipServer = IPAddress.Parse (serverIP); IPEndPoint server = new IPEndPoint (ipServer, 30001); epServer = (EndPoint)server; //Debug.Log("Enviando data de inicio de conexion: "); //string data = sendData.GetDataStream(); //byte[] dataBytes = GetBytes (data); //Enviar solicitud de conexion al servidor //clientSocket.BeginSendTo (dataBytes,0,dataBytes.Length,SocketFlags.None,epServer,new System.AsyncCallback(this.SendData),null); // Inicializando el dataStream this.dataStream = new byte[1024]; // Empezamos a escuhar respuestas del servidor clientSocket.BeginReceiveFrom(this.dataStream, 0, this.dataStream.Length, SocketFlags.None, ref epServer, new AsyncCallback(this.ReceiveData), null); } catch(FormatException e){ throw e; } catch(SocketException e){ throw e; } }
public NowinHTTPSHost(EndPoint ep, Func<HttpListenerRequest, string> method, string path) { Condition.Requires(ep).IsNotNull(); //validate the ep is within the current ip list var ips = NetUtil.GetLocalIPAddresses(); Condition.Requires(ips).Contains(ep.IPAddress); this.EndPoint = ep; //validate the platform if (!HttpListener.IsSupported) throw new NotSupportedException( "Needs Windows XP SP2, Server 2003 or later."); // A responder method is required if (method == null) throw new ArgumentException("method"); string prefix = "http://" + this.EndPoint.IPAddress.ToString() + ":" + this.EndPoint.Port + "/" + path; if (!prefix.EndsWith("/")) prefix = prefix + "/"; _listener.Prefixes.Add(prefix); _responderMethod = method; }
public void Init (Socket socket, AsyncCallback callback, object state, SocketOperation operation) { base.Init (callback, state); this.socket = socket; this.handle = socket != null ? socket.Handle : IntPtr.Zero; this.operation = operation; DelayedException = null; EndPoint = null; Buffer = null; Offset = 0; Size = 0; SockFlags = SocketFlags.None; AcceptSocket = null; Addresses = null; Port = 0; Buffers = null; ReuseSocket = false; CurrentAddress = 0; AcceptedSocket = null; Total = 0; error = 0; EndCalled = 0; }
public void ExceptionsFromTasks() { StartPoint<int> start = StandardTasks.GetRangeEnumerator(1, 10); int i = 0; EndPoint<int> end = new EndPoint<int>( (int input) => { i++; throw new InvalidTimeZoneException(); } ); end.Retries = 3; Flow f = Flow.FromAsciiArt("b<--a", start, end); f.Start(); try { f.RunToCompletion(); Assert.Fail("RunToCompletion should throw any stopping exceptions from tasks"); } catch (InvalidTimeZoneException) { } Console.WriteLine("Exceptions thown : {0}", i); Console.WriteLine("Status of flow after error: \n{0}", f.GetStateSnapshot()); Assert.AreEqual(RunStatus.Error, end.Status); Assert.AreEqual(0, end.ItemsProcessed); }
// Add a segment, where the first point shows up in the // visualization but the second one does not. (Every endpoint is // part of two segments, but we want to only show them once.) public void addSegment(float x1, float y1, float x2, float y2) { Segment segment = new Segment();//null; //EndPoint p1 = {begin, x, y, angle,segment, visualize}; //EndPoint p1 = new EndPoint.Init(begin = false, x = 0F, y= 0F, angle = 0F,segment = segment, visualize = true); //EndPoint p2 = new EndPoint.Init(begin = false, x = 0F, y= 0F, angle = 0F,segment = segment, visualize = false); EndPoint p1 = new EndPoint{begin = false, x = 0F, y = 0F, angle = 0F,segment = segment, visualize = true}; EndPoint p2 = new EndPoint{begin = false, x = 0F, y = 0F, angle = 0F,segment = segment, visualize = false}; //EndPoint p2 = {begin: false, x: 0.0, y: 0.0, angle: 0.0,segment: segment, visualize: false}; //segment = {p1: p1, p2: p2, d: 0.0}; p1.x = x1; p1.y = y1; p2.x = x2; p2.y = y2; p1.segment = segment; p2.segment = segment; segment.p1 = p1; segment.p2 = p2; segments.Add(segment); //segments.append(segment); endpoints.Add(p1); //endpoints.append(p1); endpoints.Add(p2); //endpoints.append(p2); //Drawline lags one frame behind because off is updated after, no problem //Debug.DrawLine(new Vector3(p1.x,0F,p1.y)+off,new Vector3(p2.x,0F,p2.y)+off,new Color(1F,1F,1F,0.5F),0F,false); }
public string BangChengMessageBYSocket() { IPAddress serverIPAddress = IPAddress.Parse("127.0.0.1");//服务IP地址 int serverPort = 10001;//端口号 _client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _remoteEndPoint = new IPEndPoint(serverIPAddress, serverPort); string Command = "Subscribe";//类型(订阅Subscribe/停止订阅UnSubscribe/发布Publish) string message = Command + "," + "1001"; _client.SendTo(Encoding.ASCII.GetBytes(message), _remoteEndPoint); _data = new byte[1024]; try { EndPoint publisherEndPoint = _client.LocalEndPoint; _recv = _client.ReceiveFrom(_data, ref publisherEndPoint); string msg = Encoding.ASCII.GetString(_data, 0, _recv) + "," + publisherEndPoint.ToString(); string value = msg.Split(",".ToCharArray())[1].ToString(); return string.Format("{0:F2}", value); } catch { return "0"; } }
public static Animation CreateCounterExample2(Lifetime life) { var animation = new Animation(); var state = Ani.Anon(step => { var t = (step.TotalSeconds * 8).SmoothCycle(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); var t1 = TimeSpan.Zero; var t2 = t.Seconds(); var ra = new EndPoint("Robot A", skew: 0.Seconds() + t1); var rb = new EndPoint("Robot B", skew: 0.Seconds() + t2); var graph = new EndPointGraph( new[] { ra, rb }, new Dictionary<Tuple<EndPoint, EndPoint>, TimeSpan> { {Tuple.Create(ra, rb), 2.Seconds() + t2 - t1}, {Tuple.Create(rb, ra), 2.Seconds() + t1 - t2}, }); var m1 = new Message("I think it's t=0s.", graph, ra, rb, ra.Skew + 0.Seconds()); var m2 = new Message("Received at t=2s", graph, rb, ra, m1.ArrivalTime); var s1 = new Measurement("Apparent Time Mistake = 2s+2s", ra, ra, m2.ArrivalTime, m2.ArrivalTime + 4.Seconds(), 60); var s2 = new Measurement("Time mistake = RTT - 4s", ra, ra, m2.ArrivalTime + 4.Seconds(), m2.ArrivalTime + 4.Seconds(), 140); return new GraphMessages(graph, new[] { m1, m2}, new[] { s1, s2}); }); return CreateNetworkAnimation(animation, state, life); }
public UDPSocket(int port, uint bufferSize) { socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPAddress localIP = IPAddress.Any; localEndPoint = new IPEndPoint(localIP, port); receiveBuffer = new byte[bufferSize]; }
public SocketTestClient( ITestOutputHelper log, string server, int port, int iterations, string message, Stopwatch timeProgramStart) { _log = log; _server = server; _port = port; _endpoint = new DnsEndPoint(server, _port); _sendString = message; _sendBuffer = Encoding.UTF8.GetBytes(_sendString); _bufferLen = _sendBuffer.Length; _recvBuffer = new byte[_bufferLen]; _timeProgramStart = timeProgramStart; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // on Unix, socket will be created in Socket.ConnectAsync { _timeInit.Start(); _s = new Socket(SocketType.Stream, ProtocolType.Tcp); _timeInit.Stop(); } _iterations = iterations; }
private void BeginReceive() { buffer = new byte[4 * 4]; remoteEP = new IPEndPoint(0, 0); callback = new AsyncCallback(EndReceive); localSocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref remoteEP, callback, (object)this); }
public void Merge(EndPoint newEndPoint) { foreach (var address in newEndPoint.Addresses) { if (!Addresses.Contains(address)) Addresses.Add(address); } }
public static Task ConnectAsync(this Socket socket, EndPoint remoteEndPoint) { return Task.Factory.FromAsync( (targetEndPoint, callback, state) => ((Socket)state).BeginConnect(targetEndPoint, callback, state), asyncResult => ((Socket)asyncResult.AsyncState).EndConnect(asyncResult), remoteEndPoint, state: socket); }
public Host(EndPoint ep, LogicOfTo<string, string> logic= null, Func<System.Net.IPEndPoint, bool> validateClientEndPointStrategy = null) : base(ep, logic) { this.ValidateClientEndPointStrategy = validateClientEndPointStrategy; this.Initialize(); this.Start(); }
/// <summary> /// Creates a new OAuth protected requests. /// </summary> /// <remarks> /// Since neither a request token nor an access token is supplied, /// the user will have to authorize this request. /// </remarks> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <returns>An OAuth protected request for the protected resource</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings) { return OAuthRequest.Create( resourceEndPoint, settings, new EmptyToken(settings.Consumer.Key, TokenType.Access), new EmptyToken(settings.Consumer.Key, TokenType.Request)); }
public void Connect(string ip, int port) { if (_connecting || _connected) return; _connecting = true; _serverEP = new IPEndPoint(IPAddress.Parse(ip), port); _connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _connection.BeginConnect(_serverEP, new AsyncCallback(ConnectCallBack), null); }
public static void ReceiveFromAPM(this Socket socket, byte[] buffer, int offset, int count, SocketFlags flags, EndPoint remoteEndpoint, Action<int, EndPoint> handler) { var callback = new AsyncCallback(asyncResult => { int received = ((Socket)asyncResult.AsyncState).EndReceiveFrom(asyncResult, ref remoteEndpoint); handler(received, remoteEndpoint); }); socket.BeginReceiveFrom(buffer, offset, count, flags, ref remoteEndpoint, callback, socket); }
public void ConnectingPolymorphicTypes() { StartPoint<B> s = new StartPoint<B>((IWritableQueue<B> q) => q.Send(new B())); EndPoint<A> e = new EndPoint<A>((A q) => { }); Flow flow = new Flow(); flow.AddNode(s); flow.AddNode(e); flow.ConnectNodes(s, e, 0); }
public static void ConnectAPM(this Socket socket, EndPoint remoteEndpoint, Action handler) { var callback = new AsyncCallback(asyncResult => { ((Socket)asyncResult.AsyncState).EndConnect(asyncResult); handler(); }); socket.BeginConnect(remoteEndpoint, callback, socket); }
public void RegisterToServer(EndPoint serverEP, int playerID, byte[] sessionKey) { _serverEP = serverEP; _playerID = playerID; SendMessage(PackageType.RegisterUDP, new UDPRegisterData(playerID, sessionKey), _serverEP); BeginReceive(); }
/// <summary> /// runs "netsh http add sslcert.." /// </summary> public static void WireSSLCertToHttpSys(System.Security.Cryptography.X509Certificates.X509Certificate2 cert, EndPoint ep) { var certHash = cert.Thumbprint; var appid = EnvironmentUtil.GetRunningAssemblyGUID(); string template = Environment.SystemDirectory + "\\netsh http add sslcert ipport={0}:{1} certhash={2} appid={3}"; var cmd = string.Format(template, ep.IPAddress.ToString(), ep.Port, certHash, "{" + appid + "}"); ProcessUtil.Do(cmd); }
public void StartReceive() { if (receiveSocket != null) StopReceive(); receiveSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); bindEndPoint = new IPEndPoint(IPAddress.Any, 3001); recBuffer = new byte[maxBuffer]; receiveSocket.Bind(bindEndPoint); receiveSocket.BeginReceiveFrom(recBuffer, 0, recBuffer.Length, SocketFlags.None, ref bindEndPoint, new AsyncCallback(MessageReceivedCallback), (object)this); }
static EndPointsManager() { foreach (var property in typeof(Paths).GetFields()) { var path = (string)property.GetValue(null); var endPoint = new EndPoint(path); EndPoints.Add(endPoint); } EndPoints.Sort(); }
public SocketTestServerAPM(int numConnections, int receiveBufferSize, EndPoint localEndPoint) { _log = VerboseTestLogging.GetInstance(); _receiveBufferSize = receiveBufferSize; socket = new Socket(localEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); socket.Bind(localEndPoint); socket.Listen(numConnections); socket.BeginAccept(OnAccept, null); }
public static SocketTestServer SocketTestServerFactory( int numConnections, int receiveBufferSize, EndPoint localEndPoint) { return SocketTestServerFactory( s_implementationType, numConnections, receiveBufferSize, localEndPoint); }
internal static EndPoint<string> GetEndpoint(List<string> output) { EndPoint<string> n = new EndPoint<string>( (string i) => { output.Add(i); Thread.Sleep(10); } ); return n; }
public void testEndPoint() { var class2 = new EndPoint(Paths.byMakeModelYear); Assert.AreEqual(class2.ArgNames[0], "make"); Assert.AreEqual(class2.ArgNames[1], "model"); Assert.AreEqual(class2.ArgNames[2], "year"); class2 = new EndPoint(Paths.byModel); Assert.AreEqual(class2.ArgNames[0], "make"); Assert.AreEqual(class2.ArgNames[1], "model"); }
private Socket socket; // socket server is binding to #endregion Fields #region Methods // initialization void Start() { client = System.Convert.ToBoolean((GetComponent("SystemProperties") as SystemProperties).props.getProperty("client")); if(!client){ socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint ipLocal = new IPEndPoint ( IPAddress.Any , 10001); socket.Bind( ipLocal ); IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); Remote = (EndPoint)(sender); print("socket opened"); } }
public SubscriptionDocumentsFetcher(DocumentDatabase db, int maxBatchSize, long subscriptionId, EndPoint remoteEndpoint, string collection, bool revisions, SubscriptionState subscription, SubscriptionPatchDocument patch) { _db = db; _logger = LoggingSource.Instance.GetLogger <SubscriptionDocumentsFetcher>(db.Name); _maxBatchSize = maxBatchSize; _subscriptionId = subscriptionId; _remoteEndpoint = remoteEndpoint; _collection = collection; _revisions = revisions; _subscription = subscription; _patch = patch; }
public Boolean HeartbeatFromUnknown(EndPoint endPoint) { Console.WriteLine("Heartbeat from unknown client '{0}'", endPoint); return(false); }
public void Closed_ShouldReturnInclusive() { var closedPoint = EndPoint <float> .Closed(5f); Assert.That(closedPoint.Inclusive); }
private protected override IConnector CreateConnector(EndPoint addr, INetworkProxy?proxy) => new TcpConnector(this, Communicator, Name, Type, addr, proxy, SourceAddress, Timeout, ConnectionId);
public void Start() { IPHostEntry hostEntry = Dns.GetHostEntry(Host); IPAddress ipAddress = hostEntry.AddressList[1]; neighborClient = new UdpClient(UpdatePort); IPEndPoint sender = new IPEndPoint(IPAddress.Any, UpdatePort); EndPoint neighborRouter = (EndPoint)sender; // Data buffer for incoming data. byte[] bytes = new byte[1024]; // read file ReadConfig(); WriteToFile("Starting: " + Directory); SendUMessage(); // Bind the socket to the local endpoint and // listen for incoming connections. try { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); while (true) { ArrayList listenList = new ArrayList(); ArrayList acceptList = new ArrayList(); // bind sockets to ports. Update = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Update.Bind(new IPEndPoint(ipAddress, UpdatePort)); Command = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Command.Bind(new IPEndPoint(ipAddress, CommandPort)); listenList.Add(Update); listenList.Add(Command); Socket.Select(listenList, null, null, 10 - watch.Elapsed.Seconds); int read = 0; for (int i = 0; i < listenList.Count; i++) { read = ((Socket)listenList[i]).ReceiveFrom(bytes, ref neighborRouter); if (read > 0) { string msg = Encoding.ASCII.GetString(bytes, 0, read); ProcessMessage(msg, neighborRouter); } } if (watch.Elapsed.Seconds >= 10) { Write((watch.ElapsedMilliseconds / 1000.00)); SendUMessage(); watch.Restart(); } ShutdownSockets(); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Read(); } }
bool IAuthorizeRemotingConnection.IsConnectingEndPointAuthorized(EndPoint endPoint) { Console.WriteLine("新客户IP : " + endPoint); return(true); }
public static HubConnectionBuilder WithClientBuilder(this HubConnectionBuilder hubConnectionBuilder, EndPoint endPoint, Action <ClientBuilder> configure) { hubConnectionBuilder.Services.AddSingleton <IConnectionFactory>(sp => { var builder = new ClientBuilder(sp); configure(builder); return(builder.Build()); }); hubConnectionBuilder.Services.AddSingleton(endPoint); return(hubConnectionBuilder); }
public void Value_ShouldReturnCorrectValue() { var start = new EndPoint <int>(3); Assert.That(start.Value, Is.EqualTo(3)); }
/// <summary> /// /// </summary> public ClientSocket(SocketSetting setting, ISocketBufferProvider bufferProvider, EndPoint serverEndPoint, ISocketProtocol socketProtocol = null, EndPoint localEndPoint = null) { this.serverEndPoint = serverEndPoint; this.localEndPoint = localEndPoint; this.bufferProvider = bufferProvider; this.socketProtocol = socketProtocol; this.eventHandlers = new List <ResultEventHandler <OnReceivedSocketEventArgs, byte[]> >(); this.socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp) { ReceiveBufferSize = setting.ReceiveBufferSize, SendBufferSize = setting.SendBufferSize, NoDelay = true, Blocking = false, }; //用来控制开始连接超时检查 this.manualResetEvent = new System.Threading.ManualResetEvent(false); }
public static async Task SendTrapV1Async(EndPoint receiver, IPAddress agent, OctetString community, ObjectIdentifier enterprise, GenericCode generic, int specific, uint timestamp, IList <Variable> variables) { var message = new TrapV1Message(VersionCode.V1, agent, community, enterprise, generic, specific, timestamp, variables); await message.SendAsync(receiver).ConfigureAwait(false); }
public static void SendTrapV1(EndPoint receiver, IPAddress agent, OctetString community, ObjectIdentifier enterprise, GenericCode generic, int specific, uint timestamp, IList <Variable> variables) { var message = new TrapV1Message(VersionCode.V1, agent, community, enterprise, generic, specific, timestamp, variables); message.Send(receiver); }
public static Task ConnectAsync(this Socket socket, EndPoint endPoint) { return(socket.ConnectAsync(endPoint, CancellationToken.None)); }
public SocketClientSettings(EndPoint endPoint) { BufferSize = 16384; NumberOfSaeaForRecSend = 2; ServerEndPoint = endPoint; }
public void Equals_ShouldReturnCorrectResult(EndPoint <int> first, EndPoint <int> second, int equality) { var expected = equality == 0; Assert.That(first.Equals(second), Is.EqualTo(expected)); }
public override bool IsMatch(EndPoint endpoint) => endpoint is DnsEndPoint dnsep && dnsep.Host.EndsWith(_domainSuffix);
/// <summary> /// /// </summary> public ClientSocket(SocketSetting setting, EndPoint serverEndPoint, ISocketProtocol socketProtocol = null, EndPoint localEndPoint = null) : this(setting, new SocketBufferProvider(setting), serverEndPoint, socketProtocol, localEndPoint) { }
/// <summary> /// Initializes a new instance of the <see cref="TransportInformation"/> class. /// </summary> /// <param name="compression">The compression.</param> /// <param name="encryption">The encryption.</param> /// <param name="isConnected">if set to <c>true</c> [is connected].</param> /// <param name="localEndPoint">The local end point.</param> /// <param name="remoteEndPoint">The remote end point.</param> /// <param name="options">The options.</param> public TransportInformation(SessionCompression compression, SessionEncryption encryption, bool isConnected, EndPoint localEndPoint, EndPoint remoteEndPoint, IReadOnlyDictionary <string, object> options) { Compression = compression; Encryption = encryption; IsConnected = isConnected; LocalEndPoint = localEndPoint; RemoteEndPoint = remoteEndPoint; Options = options; }
internal ConnectionPacket(EndPoint remoteEndPoint, Dictionary <string, string> cookies) : base(remoteEndPoint, WebSocketAction.Connect, string.Empty) { Cookies = cookies; }
protected ConnectionSettings(EndPoint endPoint) { EndPoint = endPoint; }
protected override void DoBind(EndPoint localAddress) { Socket.Bind(localAddress); }
public static HubConnectionBuilder WithConnectionFactory(this HubConnectionBuilder hubConnectionBuilder, IConnectionFactory connectionFactory, EndPoint endPoint) { hubConnectionBuilder.Services.AddSingleton(connectionFactory); hubConnectionBuilder.Services.AddSingleton(endPoint); return(hubConnectionBuilder); }
void Udp_receiveevent(byte command, string data, EndPoint iep) { P2PreceiveEvent?.Invoke(command, data, iep); }
public abstract IOutputStream Create(Stream input_stream, Stream output_stream, EndPoint remote_endpoint, AccessControlInfo access_control, Guid channel_id, byte[] header);
internal Task <int> SendToAsync(ArraySegment <byte> buffer, SocketFlags socketFlags, EndPoint remoteEP) { var tcs = new TaskCompletionSource <int>(this); BeginSendTo(buffer.Array, buffer.Offset, buffer.Count, socketFlags, remoteEP, iar => { var innerTcs = (TaskCompletionSource <int>)iar.AsyncState; try { innerTcs.TrySetResult(((Socket)innerTcs.Task.AsyncState).EndSendTo(iar)); } catch (Exception e) { innerTcs.TrySetException(e); } }, tcs); return(tcs.Task); }
public void ConnectionClosed(EndPoint endPoint) { connectionCount--; Console.WriteLine("Close Connection ({0} connections)", connectionCount); }
internal Task <SocketReceiveMessageFromResult> ReceiveMessageFromAsync(ArraySegment <byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint) { var tcs = new StateTaskCompletionSource <SocketFlags, EndPoint, SocketReceiveMessageFromResult>(this) { _field1 = socketFlags, _field2 = remoteEndPoint }; BeginReceiveMessageFrom(buffer.Array, buffer.Offset, buffer.Count, socketFlags, ref tcs._field2, iar => { var innerTcs = (StateTaskCompletionSource <SocketFlags, EndPoint, SocketReceiveMessageFromResult>)iar.AsyncState; try { IPPacketInformation ipPacketInformation; int receivedBytes = ((Socket)innerTcs.Task.AsyncState).EndReceiveMessageFrom(iar, ref innerTcs._field1, ref innerTcs._field2, out ipPacketInformation); innerTcs.TrySetResult(new SocketReceiveMessageFromResult { ReceivedBytes = receivedBytes, RemoteEndPoint = innerTcs._field2, SocketFlags = innerTcs._field1, PacketInformation = ipPacketInformation }); } catch (Exception e) { innerTcs.TrySetException(e); } }, tcs); return(tcs.Task); }
public int CompareTo_ShouldReturnCorrectOrder(int value, int compareTo) { var endPoint = new EndPoint <int>(value); return(endPoint.CompareTo(compareTo)); }
public void Open_ShouldReturnNonInclusive() { var openPoint = EndPoint <float> .Open(5f); Assert.That(openPoint.Inclusive, Is.False); }
public void ImplicitConversion_ShouldSetCorrectValue() { EndPoint <int> start = 2; Assert.That(start.Value, Is.EqualTo(2)); }
public void CompareTo_ShouldReturnCorrectOrder(EndPoint <int> first, EndPoint <int> second, int expected) { var result = first.CompareTo(second); Assert.That(result, Is.EqualTo(expected)); }