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


C# EndPoint.ToString方法代码示例

本文整理汇总了C#中System.Net.EndPoint.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# EndPoint.ToString方法的具体用法?C# EndPoint.ToString怎么用?C# EndPoint.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.EndPoint的用法示例。


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

示例1: run

        public void run() {

            //MESSAGE
            System.Windows.Forms.MessageBox.Show("Waiting for client...");

            IPEndPoint sender = new IPEndPoint(IPAddress.Any, this.PORT);
            client = (EndPoint)sender;

            //MESSAGE
            System.Windows.Forms.MessageBox.Show("Client Connected at : {0} ", client.ToString());

            while (isRunning) {
                data = new byte[1024];
                recv = serverSocket.ReceiveFrom(data, ref client);

                if (recv == 0)
                {
                    System.Windows.Forms.MessageBox.Show("Client Connection Lost at : {0} ", client.ToString());
                    isRunning = false;
                    break;
                }
                //MESSAGE
                System.Windows.Forms.MessageBox.Show(Encoding.ASCII.GetString(data, 0, recv) + " " + client.ToString());


                //PARSE THE DATA AND UPDATE THE AIRCRAFT

            }
            serverSocket.Close();
        }
开发者ID:suas-anadolu,项目名称:groundstation,代码行数:30,代码来源:NetworkConnection.cs

示例2: Connect

        public void Connect(EndPoint endPoint)
        {
            byte[] data = new byte[1024];
            string input, stringData;
            int recv;
            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            int sockopt = (int)server.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout);
            Console.WriteLine("Default timeout: {0}", sockopt);
            server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, _timeout);
            sockopt = (int)server.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout);
            Console.WriteLine("New timeout: {0}", sockopt);

            string welcome = "Hello, are you there?";
            data = Encoding.ASCII.GetBytes(welcome);
            server.SendTo(data, data.Length, SocketFlags.None, endPoint);

            data = new byte[1024];
            try
            {
                Console.WriteLine("Waiting from {0}:", endPoint.ToString());
                recv = server.ReceiveFrom(data, ref endPoint);
                Console.WriteLine("Message received from {0}:", endPoint.ToString());
                Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
            }
            catch (SocketException e)
            {
                if (e.SocketErrorCode == SocketError.HostUnreachable)
                    throw new Exception("CLOSED");
                throw new Exception("TIME_OUT");
            }
            Console.WriteLine("Stopping client");
            server.Close();
        }
开发者ID:rqx110,项目名称:NScanner,代码行数:33,代码来源:UdpConnectCall.cs

示例3: Permit

 public void Permit(EndPoint endPoint)
 {
     if (permited != null)
     {
         if (permited.ContainsKey(endPoint.ToString()) == false)
             permited.Add(endPoint.ToString(), null);
     }
 }
开发者ID:vf1,项目名称:turnserver,代码行数:8,代码来源:PermissionsList.cs

示例4: addToFileList

 private void addToFileList(List<string> files, EndPoint endPoint)
 {
     string directoryFile = @".\PeerDirectory\" + endPoint.ToString().Split(':')[0] + "_" + files.ElementAt(0) + ".txt"; // The file where we want to save the client/file informaiton
     files.RemoveAt(0); // removes port number from beginning of file list
     File.WriteAllLines(directoryFile, files); // Write all the data in the list to the file.
     // Save the list of files from the client to the directory.
 }
开发者ID:AnonymousGnome,项目名称:NapsterProject,代码行数:7,代码来源:ClientHandler.cs

示例5: AcceptConnection

        public static bool AcceptConnection(EndPoint ipAddress)
        {
            MaxConnections.AddConnection(ipAddress);

            string tempIP = ipAddress.ToString().Split(':')[0];
            return (_connections[tempIP] <= _maxConnections);
        }
开发者ID:xNexus9,项目名称:tabula-rasa-server-emulator,代码行数:7,代码来源:MaxConnections.cs

示例6: CreateClient

        /// <summary>
        /// 创建客户端。
        /// </summary>
        /// <param name="endPoint">终结点。</param>
        /// <returns>传输客户端实例。</returns>
        public ITransportClient CreateClient(EndPoint endPoint)
        {
            var key = endPoint.ToString();
            return _clients.GetOrAdd(key, k => new Lazy<ITransportClient>(() =>
            {
                var messageListener = new MessageListener();
                Func<TcpSocketSaeaClient> clientFactory = () =>
                {
                    var client = new TcpSocketSaeaClient((IPEndPoint)endPoint, async (c, data, offset, count) =>
                     {
                         if (_logger.IsEnabled(LogLevel.Information))
                             _logger.LogInformation("接收到数据包。");

                         var transportMessageDecoder = _transportMessageCodecFactory.GetDecoder();
                         var transportMessageEncoder = _transportMessageCodecFactory.GetEncoder();
                         var message = transportMessageDecoder.Decode(data.Skip(offset).Take(count).ToArray());

                         if (_logger.IsEnabled(LogLevel.Information))
                             _logger.LogInformation("接收到消息:" + message.Id);

                         await messageListener.OnReceived(new SimpleClientMessageSender(transportMessageEncoder, c), message);
                     });
                    client.Connect().Wait();
                    return client;
                };
                return new TransportClient(new SimpleClientMessageSender(_transportMessageCodecFactory.GetEncoder(), clientFactory), messageListener, _logger, _serviceExecutor);
            })).Value;
        }
开发者ID:yaozd,项目名称:Rpc,代码行数:33,代码来源:SimpleTransportClientFactory.cs

示例7: IsPermited

        public bool IsPermited(EndPoint endPoint)
        {
            if (permited == null)
                return true;

            return permited.ContainsKey(endPoint.ToString());
        }
开发者ID:vf1,项目名称:turnserver,代码行数:7,代码来源:PermissionsList.cs

示例8: sendAnswer

 private static void sendAnswer(EndPoint ep)
 {
     try
     {
         string ipStr = ep.ToString().Split(':')[0];
         TcpClient client = new TcpClient(ipStr, 9999);
         if (client.Connected)
         {
             Socket s = client.Client;
             s.Send(Encoding.ASCII.GetBytes(ipStr));
             s.Close();
         }
         client.Close();
     }
     catch(Exception ex) { Console.WriteLine("error with {0}\n{1}", ep.ToString().Split(':')[0], ex.ToString()); }
 }
开发者ID:jiashida,项目名称:super-trojan-horse,代码行数:16,代码来源:BroadCastWaiter.cs

示例9: KinectClient

 public KinectClient(EndPoint endPoint)
 {
     Name = "Client_" + i;
     IP = endPoint.ToString().Split(':')[0];
     Connected = true;
     i++;
 }
开发者ID:frksptr,项目名称:kinect-demo,代码行数:7,代码来源:KinectClient.cs

示例10: CreateClient

        /// <summary>
        /// 创建客户端。
        /// </summary>
        /// <param name="endPoint">终结点。</param>
        /// <returns>传输客户端实例。</returns>
        public ITransportClient CreateClient(EndPoint endPoint)
        {
            var key = endPoint.ToString();
            if (_logger.IsEnabled(LogLevel.Debug))
                _logger.Debug($"准备为服务端地址:{key}创建客户端。");
            return _clients.GetOrAdd(key
                , k => new Lazy<ITransportClient>(() =>
                {
                    var messageListener = new MessageListener();

                    _bootstrap.Handler(new ActionChannelInitializer<ISocketChannel>(c =>
                    {
                        var pipeline = c.Pipeline;
                        pipeline.AddLast(new LengthFieldPrepender(4));
                        pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));
                        pipeline.AddLast(new DefaultChannelHandler(messageListener));
                    }));

                    var bootstrap = _bootstrap;
                    var channel = bootstrap.ConnectAsync(endPoint);
                    var messageSender = new NettyMessageClientSender(channel);
                    var client = new TransportClient(messageSender, messageListener, _logger, _serializer);
                    return client;
                }
                )).Value;
        }
开发者ID:yhhno,项目名称:Rpc,代码行数:31,代码来源:TransportClientFactory.cs

示例11: AsyncReader

 public AsyncReader(IByteParser parser, byte[] buffer, IAcceptor acceptor, ISocketErrorHandler errorHandler, Socket socket)
 {
     _parser = parser;
     _buffer = buffer;
     _acceptor = acceptor;
     _errorHandler = errorHandler;
     _socket = socket;
     _endpoint = socket.RemoteEndPoint;
     _log = LogManager.GetLogger(_endpoint.ToString());
 }
开发者ID:ArturD,项目名称:Daemons,代码行数:10,代码来源:AsyncReader.cs

示例12: AddPlayer

 /// <summary>
 /// Ensures that a player isn't already in the game and adds them
 /// </summary>
 /// <param name="playerAddress">IP address of player</param>
 /// <param name="name">Name of player</param>
 /// <returns>Boolean if the add was successful</returns>
 public Boolean AddPlayer( EndPoint playerAddress, string name)
 {
     if (!AddressLookup.ContainsKey(playerAddress.ToString()))
     {
         AddressLookup.Add(playerAddress.ToString(), NumberPlayers);
         Player p = new Player();
         p.Address = playerAddress;
         p.PlayerNumber = NumberPlayers;
         p.Name = name;
         PlayerArray.Add( p);
         NumberPlayers++;
         PlayersRemaining = NumberPlayers;
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:Twistie,项目名称:TwoServer,代码行数:25,代码来源:PlayerList.cs

示例13: CreateClient

 /// <summary>
 /// 创建客户端。
 /// </summary>
 /// <param name="endPoint">终结点。</param>
 /// <returns>传输客户端实例。</returns>
 public ITransportClient CreateClient(EndPoint endPoint)
 {
     var config = new TcpSocketSaeaClientConfiguration();
     var key = endPoint.ToString();
     return _clients.GetOrAdd(key, k => new Lazy<ITransportClient>(() =>
     {
         var messageListener = new MessageListener();
         var client = new TcpSocketSaeaClient((IPEndPoint)endPoint, new SimpleMessageDispatcher(messageListener, _transportMessageCodecFactory, _logger), config);
         client.Connect().Wait();
         return new TransportClient(new SimpleClientMessageSender(_transportMessageCodecFactory.GetEncoder(), client), messageListener, _logger, _serviceExecutor);
     })).Value;
 }
开发者ID:yonglehou,项目名称:Rpc-1,代码行数:17,代码来源:SimpleTransportClientFactory.cs

示例14: Disconnect

        public static void Disconnect(EndPoint ipAddress)
        {
            string tempIP = ipAddress.ToString().Split(':')[0];
            if (_connections.ContainsKey(tempIP))
                _connections[tempIP]--;

            if ((_connections.ContainsKey(tempIP))
                && (_connections[tempIP] == 0))
            {
                _connections.Remove(tempIP); //No connections... remove it from the list
            }
        }
开发者ID:xNexus9,项目名称:tabula-rasa-server-emulator,代码行数:12,代码来源:MaxConnections.cs

示例15: Format

        public static string Format(EndPoint endPoint)
        {
            var dnsEndPoint = endPoint as DnsEndPoint;
            if (dnsEndPoint != null)
            {
                return string.Concat(
                    dnsEndPoint.Host,
                    ":",
                    dnsEndPoint.Port.ToString());
            }

            return endPoint.ToString();
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:13,代码来源:TraceSourceEventHelper.cs


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