当前位置: 首页>>代码示例>>C#>>正文


C# EndPoint类代码示例

本文整理汇总了C#中EndPoint的典型用法代码示例。如果您正苦于以下问题:C# EndPoint类的具体用法?C# EndPoint怎么用?C# EndPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EndPoint类属于命名空间,在下文中一共展示了EndPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ServerSocket

    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");
    }
开发者ID:gjwGithub,项目名称:Cardboard,代码行数:31,代码来源:ServerSocket.cs

示例2: Arc

 public Arc(EndPoint Start, EndPoint End, double Thickness, Color Color)
 {
     this._Start = Start;
     this._End = End;
     this._Thickness = Thickness;
     this._Color = Color;
 }
开发者ID:dzamkov,项目名称:DUIP,代码行数:7,代码来源:Arc.cs

示例3: ConnectTaskAsync

 public Task ConnectTaskAsync(EndPoint endPoint)
 {
     return Task.Factory.FromAsync(
         (cb, st) => BeginConnect(endPoint, cb, st),
         ias => EndConnect(ias),
         null);
 }
开发者ID:srmcconomy,项目名称:speedrunsliveIRC,代码行数:7,代码来源:IRC.cs

示例4: UDPClient

	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;
		}
	
	}
开发者ID:PJEstrada,项目名称:proyecto1-redes,代码行数:35,代码来源:UDPClient.cs

示例5: SocketTestClient

        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;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:31,代码来源:SocketTestClient.cs

示例6: NowinHTTPSHost

        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;

        }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:27,代码来源:NowinHTTPSHost.cs

示例7: Init

		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;
		}
开发者ID:nickolyamba,项目名称:mono,代码行数:29,代码来源:SocketAsyncResult.cs

示例8: UDPSocket

 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];
 }
开发者ID:jorgeamado,项目名称:UdpNetUtils,代码行数:7,代码来源:UDPSokect.cs

示例9: ExceptionsFromTasks

 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);
 }
开发者ID:Teun,项目名称:BatchFlow,代码行数:26,代码来源:Exceptions.cs

示例10: addSegment

    // 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);
    }
开发者ID:neonwednesdays,项目名称:StealthShot-Test,代码行数:29,代码来源:VisibilityOLD.cs

示例11: CreateCounterExample2

        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);
        }
开发者ID:siddht1,项目名称:AnimatronTheTerrible,代码行数:31,代码来源:NetworkSequenceDiagram.cs

示例12: BangChengMessageBYSocket

    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";
            }
    }
开发者ID:SaintLoong,项目名称:HanCheng_CoalTraffic_BS,代码行数:26,代码来源:text.aspx.cs

示例13: BeginReceive

    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);
    }
开发者ID:michel-zimmer,项目名称:sw-minigame-unity,代码行数:7,代码来源:Rotation.cs

示例14: Create

 /// <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));
 }        
开发者ID:rpmcpp,项目名称:oauth-dot-net,代码行数:18,代码来源:OAuthConsumerRequest.cs

示例15: Host

        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();
        }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:8,代码来源:Host.cs


注:本文中的EndPoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。