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


C# TcpClient.ToString方法代码示例

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


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

示例1: SendFile

        public static void SendFile(string filePath, string fileName, TcpClient tcpClient)
        {
            try
            {

                Console.WriteLine(tcpClient.ToString() + "connected");
                NetworkStream networkstream = tcpClient.GetStream();
                FileStream fileStream = null;

                byte[] _data = new byte[1024];
                int _bytesRead = 0;

               // _bytesRead = networkstream.Read(_data, 0, _data.Length);
                fileStream = new FileStream(filePath+fileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                int byteSize = 0;

                byte[] downBuffer = new byte[4096];
                int chunkNumber = 0;
                while ((byteSize = networkstream.Read(downBuffer, 0, downBuffer.Length)) > 0)
                {
                    chunkNumber++;
                    Console.WriteLine("ChunkNummer: "+chunkNumber +" transferring : "+byteSize+" bytes");
                    fileStream.Write(downBuffer, 0, byteSize);
                }
                networkstream.Close();
                fileStream.Close();
                Console.ReadKey(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Console.ReadKey(true);

            }
        }
开发者ID:bluemangoentertainment,项目名称:Patchserver,代码行数:35,代码来源:Files.cs

示例2: startListening

        public void startListening(int port)
        {
            try
            {
                while (_continue)
                {
                    Thread.Sleep(10);
                    listener = new TcpListener(_ipAddress, port);

                    listener.Start();

                    Console.WriteLine("Listening on port " + port);
                    Console.WriteLine("The local End point is: " + listener.LocalEndpoint);

                    client = listener.AcceptTcpClient();
                    Console.WriteLine("Connection accepted from " + client.ToString());

                    byte[] bytes = new byte[8];

                    stream = client.GetStream();
                    stream.Read(bytes, 0, bytes.Length);

                    _helper.Respond(client, stream, bytes);

                    StopListening();

                }
                Console.WriteLine("server stopped");

            }
            catch (Exception e)
            {

                Console.WriteLine("Error..... " + e.ToString());
            }
        }
开发者ID:kristofberge,项目名称:StudentsServerWeb,代码行数:36,代码来源:SimpleServer.cs

示例3: ErlConnection

 /// <summary>
 /// Accept an incoming connection from a remote node
 /// </summary>
 public ErlConnection(ErlLocalNode node, TcpClient peer)
     : base(node, new ErlTcpTransport(peer))
 {
   _ctor(StringConsts.ERL_CONNECTION.Args(m_Home.NodeName.Value, "<-", peer.ToString()));
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:8,代码来源:ErlConnection.cs

示例4: Connection

 public Connection(TcpClient client, Api.Role role)
     : base(new Account(client.ToString(), role)) {
     Client = client;
 }
开发者ID:zaitsevyan,项目名称:Theseus,代码行数:4,代码来源:NetworkListener.cs

示例5: MyTcpServerConnectionClosed

 void MyTcpServerConnectionClosed(TcpClient client)
 {
     listBox1.Items.Add("Closed: " + client.ToString());            
 }
开发者ID:zvrkan5,项目名称:DotNetSiemensPLCToolBoxLibrary,代码行数:4,代码来源:NetworkPLCSim.cs

示例6: DisconnectClient

        /// <summary>
        /// Removes a given client from our list of clients
        /// </summary>
        /// <param name="client"></param>
        public void DisconnectClient(TcpClient client)
        {
            if (client == null)
            {
                return;
            }

            Console.WriteLine("Disconnected client: " + client.ToString());

            client.Close();

            clients.Remove(client);
            NetworkBuffer buffer;
            clientBuffers.TryRemove(client, out buffer);
        }
开发者ID:bschwind,项目名称:Graphics-Toolkit,代码行数:19,代码来源:Server.cs

示例7: addNewClient

        /// <summary>
        /// 
        /// </summary>
        /// <param name="p"></param>
        /// <param name="incomingClient"></param>
        /// <param name="stream"></param>
        private void addNewClient(Packet p, TcpClient incomingClient, SslStream stream)
        {
            clients.Add(p.GetID(), incomingClient);
            clientsStreams.Add(p.GetID(), stream);

            #region DEBUG
            #if DEBUG
            Console.WriteLine("ID: " + p.GetID() + "incomingClient: " + incomingClient.ToString());
            printClientList();
            #endif
            #endregion
        }
开发者ID:jackxl,项目名称:MediCare,代码行数:18,代码来源:Program.cs

示例8: Fsm

        /// <summary>
        /// Creates a new instance of DcmULService 
        /// </summary>
        public Fsm(Association assoc, TcpClient s, bool requestor)
        {
            STA1 = new State1(this, AssociationState.IDLE);
            STA2 = new State2(this, AssociationState.AWAITING_READ_ASS_RQ);
            STA3 = new State3(this, AssociationState.AWAITING_WRITE_ASS_RP);
            STA4 = new State4(this, AssociationState.AWAITING_WRITE_ASS_RQ);
            STA5 = new State5(this, AssociationState.AWAITING_READ_ASS_RP);
            STA6 = new State6(this, AssociationState.ASSOCIATION_ESTABLISHED);
            STA7 = new State7(this, AssociationState.AWAITING_READ_REL_RP);
            STA8 = new State8(this, AssociationState.AWAITING_WRITE_REL_RP);
            STA9 = new State9(this, AssociationState.RCRS_AWAITING_WRITE_REL_RP);
            STA10 = new State10(this, AssociationState.RCAS_AWAITING_READ_REL_RP);
            STA11 = new State11(this, AssociationState.RCRS_AWAITING_READ_REL_RP);
            STA12 = new State12(this, AssociationState.RCAS_AWAITING_WRITE_REL_RP);
            STA13 = new State13(this, AssociationState.ASSOCIATION_TERMINATING);
            state = STA1;

            this.assoc = assoc;
            this.requestor = requestor;
            this.s = s;
            stream = s.GetStream();
            Logger.Info(s.ToString());
            ChangeState(requestor ? STA4 : STA2);
        }
开发者ID:KnownSubset,项目名称:DicomSharp,代码行数:27,代码来源:Fsm.cs

示例9: BeginSend

		public IAsyncResult BeginSend(string host, int port, bool useTls, string callingAe, string calledAe, AsyncCallback callback, object state) {
			_client = new TcpClient(host, port);
            //zssure:2015-04-14,try to conform whether AddRequest and Send uses the same one client
            LogManager.Default.GetLogger("Dicom.Network").Info("zssure debug at 20150414,the TcpClient object is {0},HashCode{1}", _client.ToString(),_client.GetHashCode()); 
            //zssure:2015-04-14,end

			if (Options != null)
				_client.NoDelay = Options.TcpNoDelay;
			else
				_client.NoDelay = DicomServiceOptions.Default.TcpNoDelay;

			Stream stream = _client.GetStream();

			if (useTls) {
				var ssl = new SslStream(stream, false, ValidateServerCertificate);
				ssl.AuthenticateAsClient(host);
				stream = ssl;
			}

			return BeginSend(stream, callingAe, calledAe, callback, state);
		}
开发者ID:ZeryZhang,项目名称:fo-dicom,代码行数:21,代码来源:DicomClient.cs


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