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


C# Socket.ToString方法代码示例

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


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

示例1: SoftwareI2CBus

        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <remarks>This automatically checks that the socket supports Type X or Y as appropriate, and reserves the SDA and SCL pins.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket for this software I2C device interface.</param>
        /// <param name="address">The address of the I2C device.</param>
        /// <param name="clockRateKHz">The maximum clock speed supported by the I2C device.</param>
        /// <param name="sdaPin">The socket pin used for I2C data.</param>
        /// <param name="sclPin">The socket pin used for I2C clock.</param>
        /// <param name="module">The module using this I2C interface, which can be null if unspecified.</param>
        public SoftwareI2CBus(Socket socket, Socket.Pin sdaPin, Socket.Pin sclPin, ushort address, int clockRateKHz, Module module)
        {
            this.address = (byte)address;
            this.clockRateKHz = clockRateKHz;

            // see if we've already reserved the pins and got instances of the ports, otherwise do that.
            string sdaPinString = socket.ToString() + "___" + sdaPin;
            if (!ReservedSdaPinPorts.Contains(sdaPinString))
            {
                sdaPort = DigitalIOFactory.Create(socket, sdaPin, false, GlitchFilterMode.Off, ForceManagedPullUps ? ResistorMode.PullUp : ResistorMode.Disabled, module);
                ReservedSdaPinPorts.Add(sdaPinString, sdaPort);
            }
            else
            {
                sdaPort = (DigitalIO)ReservedSdaPinPorts[sdaPinString];
            }

            string sclPinString = socket.ToString() + "___" + sclPin;
            if (!ReservedSclPinPorts.Contains(sclPinString))
            {
                sclPort = DigitalIOFactory.Create(socket, sclPin, false, GlitchFilterMode.Off, ForceManagedPullUps ? ResistorMode.PullUp : ResistorMode.Disabled, module);
                ReservedSclPinPorts.Add(sclPinString, sclPort);
            }
            else
            {
                sclPort = (DigitalIO)ReservedSclPinPorts[sclPinString];
            }

            this.socket = socket;
            this.sdaPin = sdaPin;
            this.sclPin = sclPin;

            lock (SoftwareI2CTimeoutList)
            {
                timeoutCount = -1;       // Prevent the TimeoutHandler thread from watching this port for now
                SoftwareI2CTimeoutList.Add(this);

                if (timeoutThread == null)
                {
                    threadExit = false;
                    timeoutThread = new Thread(TimeoutHandler);
                    timeoutThread.Start();
                }
            }
        }
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:55,代码来源:SoftwareI2CBus.cs

示例2: SoftwareI2C

        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <remarks>This automatically checks that the socket supports Type X or Y as appropriate, and reserves the SDA and SCL pins.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket for this software I2C device interface.</param>
        /// <param name="sdaPin">The socket pin used for I2C data.</param>
        /// <param name="sclPin">The socket pin used for I2C clock.</param>
        /// <param name="module">The module using this I2C interface, which can be null if unspecified.</param>
        public SoftwareI2C(Socket socket, Socket.Pin sdaPin, Socket.Pin sclPin, Module module)
        {
            // first check the socket is compatible
            if (sclPin > Socket.Pin.Five || sdaPin > Socket.Pin.Five)
            {
                socket.EnsureTypeIsSupported('Y', module);
            }
            else
            {
                socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, module);
            }

            if (ForceManagedSoftwareI2CImplementation || socket.NativeI2CWriteRead == null) usingManaged = true;

            // then see if we've already reserved the pins and got instances of the ports, otherwise do that.
            string sdaPinString = socket.ToString() + "___" + sdaPin;
            if (!ReservedSdaPinPorts.Contains(sdaPinString))
            {
                Cpu.Pin sdaCpuPin = socket.ReservePin(sdaPin, module);
                if (usingManaged)
                {
                    sdaPort = new TristatePort(sdaCpuPin, false, false, ForceManagedPullUps ? Port.ResistorMode.PullUp : Port.ResistorMode.Disabled);
                }
                ReservedSdaPinPorts.Add(sdaPinString, sdaPort);
            }
            else
            {
                sdaPort = (TristatePort)ReservedSdaPinPorts[sdaPinString];
            }

            string sclPinString = socket.ToString() + "___" + sclPin;
            if (!ReservedSclPinPorts.Contains(sclPinString))
            {
                Cpu.Pin sclCpuPin = socket.ReservePin(sclPin, module);
                if (usingManaged)
                {
                    sclPort = new TristatePort(sclCpuPin, false, false, ForceManagedPullUps ? Port.ResistorMode.PullUp : Port.ResistorMode.Disabled);
                }
                ReservedSclPinPorts.Add(sclPinString, sclPort);
            }
            else
            {
                sclPort = (TristatePort)ReservedSclPinPorts[sclPinString];
            }

            this.socket = socket;
            this.sdaPin = sdaPin;
            this.sclPin = sclPin;

            if (usingManaged)
            {
                lock (SoftwareI2CTimeoutList)
                {
                    timeoutCount = -1;       // Prevent the TimeoutHandler thread from watching this port for now
                    SoftwareI2CTimeoutList.Add(this);

                    if (timeoutThread == null)
                    {
                        threadExit = false;
                        timeoutThread = new Thread(new ThreadStart(TimeoutHandler));
                        timeoutThread.Start();
                    }
                }
            }
        }
开发者ID:janmechan,项目名称:Gadgeteer,代码行数:73,代码来源:SoftwareI2C.cs

示例3: CancelReceiving

 public void CancelReceiving(Socket soc)
 {
     lock (this.mClientTableLock)
     {
         if (mHtClientTable.ContainsKey(soc.ToString()))
         {
             StateObject obj = mHtClientTable[soc.ToString()];
             obj.AbortFTP = true;
         }
     }
 }
开发者ID:WeDoCrm,项目名称:WeDoServer2.0,代码行数:11,代码来源:ServerListeners.cs

示例4: DisconnectIndependent

        public void DisconnectIndependent(Socket SocketToDisconnect)
        {
            try
            {
                cmd = "<SERVERKILLCONNECTION>";
                byte[] msg = Encoding.ASCII.GetBytes(cmd);
                // Send the data through the socket.
                int bytesSent = MainSocket.Send(msg);
                WriteToLog("Client says: " + cmd);
                string SocketDeets = SocketToDisconnect.ToString();
                SocketToDisconnect.Shutdown(SocketShutdown.Both);
                SocketToDisconnect.Close();
                WriteToLog("Socket disconnected... " + SocketDeets);
                txStatus.Text = "Disconnected";

            }
            catch (Exception ec)
            {
                SocketToDisconnect = null;
                txStatus.Text = ec.ToString();
                WriteToLog("Socket was already disconnected...");
            }
            SetConfigData();
            CurrentlyConnected = false;
            SocketToDisconnect = null;
        }
开发者ID:Thomas-Brothers-Workshop,项目名称:TCPClient,代码行数:26,代码来源:MainWindow.xaml.cs

示例5: listUsers_MouseDoubleClick

 /// <summary>
 /// 开启和选中项的通话
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void listUsers_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (listUsers.SelectedItem == null) return;
     var user = listUsers.SelectedItem as User;
     Socket socket=new Socket(AddressFamily.InterNetworkV6,SocketType.Stream,ProtocolType.Tcp);
     try
     {
         socket.Connect(new IPEndPoint(IPAddress.Parse(user.IP), serverPort));
         CommunicationFrm clientFrm = new CommunicationFrm(socket);
         clientFrm.Text = "客户端:" + socket.ToString();
         clientFrm.Show();
     }
     catch (Exception err)
     {
         MessageBox.Show("服务器未启动:"+err.Message);
     }
 }
开发者ID:junyong-tsui,项目名称:csharpexamples,代码行数:22,代码来源:P2PMainFrom.cs


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