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


C# IPEndPoint.ToString方法代码示例

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


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

示例1: NodeBase

		protected NodeBase(ICluster owner, IPEndPoint endpoint, IFailurePolicy failurePolicy, ISocket socket)
		{
			this.owner = owner;
			this.endpoint = endpoint;
			this.socket = socket;
			this.failurePolicy = failurePolicy;
			this.name = endpoint.ToString();

			failLock = new Object();
			writeQueue = new ConcurrentQueue<Data>();
			readQueue = new Queue<Data>();

			mustReconnect = true;
			IsAlive = true;

			counterEnqueuePerSec = Metrics.Meter("node write enqueue/sec", endpoint.ToString(), Interval.Seconds);
			counterDequeuePerSec = Metrics.Meter("node write dequeue/sec", endpoint.ToString(), Interval.Seconds);
			counterOpReadPerSec = Metrics.Meter("node op read/sec", endpoint.ToString(), Interval.Seconds);
			counterWriteQueue = Metrics.Counter("write queue length", endpoint.ToString());
			counterReadQueue = Metrics.Counter("read queue length", endpoint.ToString());

			counterWritePerSec = Metrics.Meter("node write/sec", endpoint.ToString(), Interval.Seconds);
			counterErrorPerSec = Metrics.Meter("node in error/sec", endpoint.ToString(), Interval.Seconds);
			counterItemCount = Metrics.Counter("commands", endpoint.ToString());
			gaugeSendSpeed = Metrics.Gauge("send speed", endpoint.ToString());
		}
开发者ID:adamhathcock,项目名称:EnyimMemcached2,代码行数:26,代码来源:NodeBase.cs

示例2: messageReceiver

        public void messageReceiver()
        {
            UdpClient listener = new UdpClient(receivingPort);
            IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, receivingPort);
            string received_data;
            byte[] receive_byte_array;

            try
            {
                while (true)
                {
                    Console.WriteLine("Waiting for broadcast");
                    receive_byte_array = listener.Receive(ref groupEP);
                    Console.WriteLine("Received a broadcast from {0}", groupEP.ToString());
                    string[] IPHolster = groupEP.ToString().Split(':');
                    checkedIPAddresses.Add(IPHolster[0]);
                    received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length);
                    Console.WriteLine("data follows \n{0}\n\n", received_data);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
开发者ID:Ikthios,项目名称:P2P,代码行数:25,代码来源:UDPListener.cs

示例3: Main

        static void Main(string[] args)
        {
            byte[] data = new byte[1024];
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 2005);
            UdpClient newsock = new UdpClient(ipep);

            Console.WriteLine("Waiting for a client...");

            IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);

            data = newsock.Receive(ref sender);

            Console.WriteLine("Message received from {0}:", sender.ToString());
            Console.WriteLine(Encoding.ASCII.GetString(data, 0, data.Length));

            string welcome = "Welcome to my test server";
            data = Encoding.ASCII.GetBytes(welcome);
            newsock.Send(data, data.Length, sender);

            while (true)
            {
                data = newsock.Receive(ref sender);

                Console.WriteLine("Message received from {0}:", sender.ToString());
                Console.WriteLine(Encoding.ASCII.GetString(data, 0, data.Length));
                newsock.Send(data, data.Length, sender);
            }
        }
开发者ID:RavenXce,项目名称:PowerWiFly_old,代码行数:28,代码来源:Program.cs

示例4: ServerSession

        public ServerSession(IPEndPoint ipEndPoint)
        {
            string url = "http://" + ipEndPoint.ToString() + "/api/general/getname";

            new HttpGetRequest<ServerName>(url, next);

            url = "http://" + ipEndPoint.ToString() + "/api/account/login";

            new HttpPostRequest<LoginInput,LoginOutput>(url, next2,new LoginInput("123","placek"));
        }
开发者ID:HKMOpen,项目名称:innovativeproject-meetingdataexchange,代码行数:10,代码来源:ServerSession.cs

示例5: ConvertListenException

 public static Exception ConvertListenException(SocketException socketException, IPEndPoint localEndpoint)
 {
     if (socketException.ErrorCode == 6)
     {
         return new CommunicationObjectAbortedException(socketException.Message, socketException);
     }
     if (socketException.ErrorCode == 0x2740)
     {
         return new AddressAlreadyInUseException(System.ServiceModel.SR.GetString("TcpAddressInUse", new object[] { localEndpoint.ToString() }), socketException);
     }
     return new CommunicationException(System.ServiceModel.SR.GetString("TcpListenError", new object[] { socketException.ErrorCode, socketException.Message, localEndpoint.ToString() }), socketException);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:SocketConnectionListener.cs

示例6: Node

        public Node(IPEndPoint endpoint)
        {
            this.Nodes = new Dictionary<string, HashTableEntry>();
            this.Entry = new HashTableEntry();
            this.Entry.Address = endpoint.ToString();

            hash = MD5.Create();
            byte[] bytes = Encoding.ASCII.GetBytes(endpoint.ToString());
            this.Entry.NodeId = new BigInteger(hash.ComputeHash(bytes)).ToString();
            this.Entry.LastUpdated = DateTime.MinValue;

            this.Nodes.Add(this.Entry.NodeId, this.Entry);
        }
开发者ID:kellabyte,项目名称:Ring.io,代码行数:13,代码来源:Node.cs

示例7: Node

        public Node(IPEndPoint endpoint, IMessageBusFactory messageBusFactory)
        {
            _messageBusFactory = messageBusFactory;
            this.Nodes = new Dictionary<string, HashTableEntry>();
            this.Entry = new HashTableEntry();
            this.Endpoint = endpoint;
            this.Entry.Address = endpoint.ToString();

            hash = MD5.Create();
            byte[] bytes = Encoding.ASCII.GetBytes(endpoint.ToString());
            this.Entry.NodeId = new BigInteger(hash.ComputeHash(bytes)).ToString();
            this.Entry.LastSeen = DateTime.MinValue;
        }
开发者ID:larsw,项目名称:Ring.io,代码行数:13,代码来源:Node.cs

示例8: Server

 public Server(string hostname, int port, int clientPort)
 {
     endPoint = new IPEndPoint(IPAddress.Parse(hostname), clientPort);
     server = new UdpClient(port);
     Console.WriteLine($"Server start listenning. Local End Point: {endPoint.ToString()}");
     ProcessConnection();
 }
开发者ID:mtratsiuk,项目名称:Labs,代码行数:7,代码来源:Server.cs

示例9: GenerateDefaultKeyRanges

        private static uint[] GenerateDefaultKeyRanges(IPEndPoint endPoint, int numberOfKeys)
        {
            const int KeyLength = 4;
            const int PartCount = 1; // (ModifiedFNV.HashSize / 8) / KeyLength; // HashSize is in bits, uint is 4 byte long

            var k = new uint[PartCount * numberOfKeys];

            // every server is registered numberOfKeys times
            // using UInt32s generated from the different parts of the hash
            // i.e. hash is 64 bit:
            // 00 00 aa bb 00 00 cc dd
            // server will be stored with keys 0x0000aabb & 0x0000ccdd
            // (or a bit differently based on the little/big indianness of the host)
            string address = endPoint.ToString();
            var fnv = new FNV1a();

            for (int i = 0; i < numberOfKeys; i++)
            {
                byte[] data = fnv.ComputeHash(Encoding.ASCII.GetBytes(String.Concat(address, "-", i)));

                for (int h = 0; h < PartCount; h++)
                {
                    k[i * PartCount + h] = BitConverter.ToUInt32(data, h * KeyLength);
                }
            }

            return k;
        }
开发者ID:adityaarisettybv,项目名称:MemcacheDistributionTesting,代码行数:28,代码来源:Form1.cs

示例10: Form1

        public Form1()
            : base("Desktop Viewer", 20, 20, 640, 480)
        {
            //fAutoScale = true;

            // Create the backing buffer to retain the image
            fBackingBuffer = new GDIDIBSection(1600, 1200);

            // 1.  Show a dialog box to allow the user to type in the 
            // group IP address and port number.
            HostForm groupForm = new HostForm();
            groupForm.ShowDialog();

            // 2. Get the address and port from the form, and use
            // them to setup the MultiSession object
            string groupIP = groupForm.groupAddressField.Text;
            int groupPort = int.Parse(groupForm.groupPortField.Text);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort);

            Title = "Desktop Viewer - " + ipep.ToString();

            fSession = new MultiSession(Guid.NewGuid().ToString(), ipep);
            fSketchChannel = fSession.CreateChannel(PayloadType.dynamicPresentation);

            // 3. Setup the chunk decoder so we can receive new images
            // when they come in
            fChunkDecoder = new GraphPortChunkDecoder(fBackingBuffer, fSketchChannel);
            fChunkDecoder.PixBltPixelBuffer24Handler += this.PixBltPixelBuffer24;
            fChunkDecoder.PixBltLumbHandler += this.PixBltLum24;

            fUserIOChannel = fSession.CreateChannel(PayloadType.xApplication2);
            fUserIOEncoder = new UserIOChannelEncoder(fUserIOChannel);
            fUserIODecoder = new UserIOChannelDecoder(fUserIOChannel);
            fUserIODecoder.MoveCursorEvent += MoveCursor;
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:35,代码来源:Form1.cs

示例11: Start

        public static void Start()
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;

            listener = new Socket(AddressFamily.InterNetwork,
                SocketType.Dgram, ProtocolType.Udp);

            listener.Bind(new IPEndPoint(IPAddress.Any, PORT));

            Console.WriteLine("Waiting for a connection..." + GetLocalIpAddress());

            while (true) {

                EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
                StateObject state = new StateObject();
                state.WorkSocket = listener;
                listener.ReceiveFrom(state.Buffer, ref remoteEndPoint);
                var rawMessage = Encoding.UTF8.GetString(state.Buffer);
                var messages = rawMessage.Split(';');

                if (messages.Length > 1) {
                    var command = messages[0];
                    var deviceName = messages[1];
                    Console.WriteLine("Command is received from Device Name +"+deviceName+"+");
                    string[] portno = remoteEndPoint.ToString().Split(':');
                    Send(portno[1],remoteEndPoint);

                }
            }
        }
开发者ID:ahmeda8,项目名称:audio-youtube-wp7,代码行数:30,代码来源:UdpServer.cs

示例12: Main

        public static int Main()
        {
            bool done = false;
            double received_data;
            byte[] receive_byte_array;

            UdpClient listener = new UdpClient(listenPort);
            IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);

            Console.WriteLine("Waiting for broadcast");

            try
            {
                while (!done)
                {
                    // This is the line of code that receives the broadcase message. It calls the receive function
                    // from the object listener (class UdpClient). It passes to listener the end point groupEP. It
                    // puts the data from the broadcast message into the byte array named received_byte_array. Note
                    // that this is a synchronous or blocking call.

                    receive_byte_array = listener.Receive(ref groupEP);
                    Console.WriteLine("Received a broadcast from {0}", groupEP.ToString());
                    received_data = System.BitConverter.ToDouble(receive_byte_array, 0);
                    Console.WriteLine("Data: {0} \n", received_data);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            listener.Close();
            return 0;
        }
开发者ID:knez,项目名称:test-zone,代码行数:33,代码来源:Program.cs

示例13: SIPTCPChannel

        private Dictionary<string, DateTime> m_connectionFailures = new Dictionary<string, DateTime>(); // Tracks sockets that have had a connection failure on them to avoid endless re-connect attmepts.

        public SIPTCPChannel(IPEndPoint endPoint)
        {
            m_localSIPEndPoint = new SIPEndPoint(SIPProtocolsEnum.tcp, endPoint);
            LocalTCPSockets.Add(endPoint.ToString());
            m_isReliable = true;
            Initialise();
        }
开发者ID:akalafrancis,项目名称:sipsorcery-mono,代码行数:9,代码来源:SIPTCPChannel.cs

示例14: endReceive

        private void endReceive(IAsyncResult ar)
        {
            IPEndPoint ip = new IPEndPoint(IPAddress.IPv6Any, 00000);
            byte[] data = client.EndReceive(ar, ref ip);
            Packet p = new Packet(data, ip);
            from = ip;
            Log.Debug("AYY");
            if (p.OperationID == operationID)
            {
                recv.Add(p.HandshakeID, p.GetCleanData());
                Packet reply = p.MakeReply();
                client.Send(reply._data, reply._data.Length, ip);
                Log.Info(string.Format("Received {0} bytes from {1}.", new object[] { data.Length, ip.ToString() }));
                currentCount++;
            }
            else
            {
                Log.Error(string.Format("Invalid packet Operation ID {0} expected {1}.", new object[] { p.OperationID.ToString("X"), operationID.ToString("X") }));
            }

            if(currentCount != totalCount)
            {
                client.BeginReceive(endReceive, null);
            }
            else
            {
                Log.Info(string.Format("R operation {0} has been completed successfully.", operationID.ToString("X")));
                Packet packet = GetPacket();
                client.Close();
                UdpPacketRouter.QuitReceiveOp(operationID);
                callBack(packet);
            }
        }
开发者ID:ItsElioBaby,项目名称:UDP-Router,代码行数:33,代码来源:ReceiveOperation.cs

示例15: StartListener

        private static void StartListener()
        {
            bool done = false;

            UdpClient listener = new UdpClient(listenPort);
            IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);

            try
            {
                while (!done)
                {
                    Console.WriteLine("Waiting for broadcast");
                    byte[] bytes = listener.Receive(ref groupEP);

                    Console.WriteLine("Received broadcast from {0} :\n {1}\n",
                        groupEP.ToString(),
                        Encoding.ASCII.GetString(bytes, 0, bytes.Length));
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                listener.Close();
            }
        }
开发者ID:novakvova,项目名称:lesson2,代码行数:29,代码来源:Program.cs


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