资源简介

C#写的TCP的client和server的程序,实现简单通信,源码简单

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;

namespace TcpClientDemo
{
    class Program
    {
        static void Connect(String server String message)
        {
            try
            {
                Int32 port = 13000;
                TcpClient client = new TcpClient(server port);

                /* Translate the passed message into ASCII and store it as a Byte array. */
                Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
                NetworkStream stream = client.GetStream();                
                stream.Write(data 0 data.Length);/* Send the message to the connected TcpServer.  */

                Console.WriteLi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5632  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\bin\Debug\TcpClientDemo.exe

     文件      13824  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\bin\Debug\TcpClientDemo.pdb

     文件      11608  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\bin\Debug\TcpClientDemo.vshost.exe

     文件        490  2010-03-17 22:39  TCP IP通信\TcpClientDemo\TcpClientDemo\bin\Debug\TcpClientDemo.vshost.exe.manifest

     文件       5768  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1289  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\obj\Debug\TcpClientDemo.csproj.FileListAbsolute.txt

     文件       5632  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\obj\Debug\TcpClientDemo.exe

     文件      13824  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\obj\Debug\TcpClientDemo.pdb

     文件       2087  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\Program.cs

     文件       1382  2012-08-15 10:03  TCP IP通信\TcpClientDemo\TcpClientDemo\Properties\AssemblyInfo.cs

     文件       2781  2012-09-28 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo\TcpClientDemo.csproj

     文件        929  2012-09-28 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo.sln

    ..A..H.     15872  2012-10-11 09:09  TCP IP通信\TcpClientDemo\TcpClientDemo.suo

     文件       5632  2012-10-11 09:09  TCP IP通信\TcpListenerDemo\TcpListenerDemo\bin\Debug\TcpListenerDemo.exe

     文件      13824  2012-10-11 09:09  TCP IP通信\TcpListenerDemo\TcpListenerDemo\bin\Debug\TcpListenerDemo.pdb

     文件      11608  2012-10-11 09:11  TCP IP通信\TcpListenerDemo\TcpListenerDemo\bin\Debug\TcpListenerDemo.vshost.exe

     文件        490  2010-03-17 22:39  TCP IP通信\TcpListenerDemo\TcpListenerDemo\bin\Debug\TcpListenerDemo.vshost.exe.manifest

     文件       5776  2012-10-11 09:09  TCP IP通信\TcpListenerDemo\TcpListenerDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1373  2012-10-11 09:11  TCP IP通信\TcpListenerDemo\TcpListenerDemo\obj\Debug\TcpListenerDemo.csproj.FileListAbsolute.txt

     文件       5632  2012-10-11 09:09  TCP IP通信\TcpListenerDemo\TcpListenerDemo\obj\Debug\TcpListenerDemo.exe

     文件      13824  2012-10-11 09:09  TCP IP通信\TcpListenerDemo\TcpListenerDemo\obj\Debug\TcpListenerDemo.pdb

     文件       2378  2012-10-11 09:09  TCP IP通信\TcpListenerDemo\TcpListenerDemo\Program.cs

     文件       1386  2012-08-15 10:07  TCP IP通信\TcpListenerDemo\TcpListenerDemo\Properties\AssemblyInfo.cs

     文件       2785  2012-09-28 09:08  TCP IP通信\TcpListenerDemo\TcpListenerDemo\TcpListenerDemo.csproj

     文件        935  2012-09-28 09:08  TCP IP通信\TcpListenerDemo\TcpListenerDemo.sln

    ..A..H.     16896  2012-10-11 09:11  TCP IP通信\TcpListenerDemo\TcpListenerDemo.suo

     目录          0  2012-08-15 10:03  TCP IP通信\TcpClientDemo\TcpClientDemo\obj\Debug\TempPE

     目录          0  2012-08-15 10:21  TCP IP通信\TcpListenerDemo\TcpListenerDemo\obj\Debug\Refactor

     目录          0  2012-08-15 10:07  TCP IP通信\TcpListenerDemo\TcpListenerDemo\obj\Debug\TempPE

     目录          0  2012-09-28 15:59  TCP IP通信\TcpClientDemo\TcpClientDemo\bin\Debug

............此处省略19个文件信息

评论

共有 条评论