资源简介


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace TCP
{
    public partial class Form1 : Form
    {
        public delegate void display(string msg);
        public delegate void dis_con();
        public bool recv_th = true;
        public bool server_th = true;
        public Socket tcp_client;
        public Socket tcp_server;
        public Socket soc;
        
        public Form1()
        {
            
            InitializeComponent();
           
            Obtain_hostip();
            port.Text = “8000“;
            choose.Items.Add(“TCP server“);
            choose.Items.Add(“TCP client“);
            


    
        }

        private void allow()
        {
            if (choose.InvokeRequired == false)
            {
                button2.Text = “connect“;
                IP.Enabled = true;
                port.Enabled = true;
                choose.Enabled = true;
            }
            else
            {
                dis_con dis = new dis_con(allow);
                button2.Invoke(dis);
            
            }

        }


        private void Prohibited()
        {
            IP.Enabled = false;
            port.Enabled = false;
            choose.Enabled = false;
        
        }
        private void dis_msg(string msg)
        {
            if (display_data.InvokeRequired == false)
            {
                display_data.AppendText(msg);

            }
            else
            {
                display fd = new display(dis_msg);
                display_data.Invoke(fdmsg);
            
            }
        
        
        }

        private void recv(object ch)
        {

            if (ch.ToString() == “TCP client“)
            {
                while (recv_th)
                {
                    try
                    {
                        int length = tcp_client.ReceiveBufferSize;
                        byte[] recv_data = new byte[length];
                        int recv_length = tcp_client.Receive(recv_data);
                        if (recv_length == 0)
                        {
                            MessageBox.Show(“server disconnecting “ “error“);
                            allow();
                            break;
                        }
                        string data = DateTime.Now.ToString(“yyyy-MM-dd/hh/mm/ss-->recv:“) + Encoding.UTF8.GetString(recv_data0recv_length) + “\n“;
                        dis_msg(data);
                    }
                    catch (SocketException msg)
                    {
                        return;
                    
                    }


                }
            }
    

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

     文件        189  2019-01-08 14:42  TCP\TCP\App.config

     文件     190464  2019-01-09 17:49  TCP\TCP\bin\Debug\TCP.exe

     文件        189  2019-01-08 14:42  TCP\TCP\bin\Debug\TCP.exe.config

     文件      28160  2019-01-09 17:49  TCP\TCP\bin\Debug\TCP.pdb

     文件      22984  2019-01-09 17:49  TCP\TCP\bin\Debug\TCP.vshost.exe

     文件        189  2019-01-08 14:42  TCP\TCP\bin\Debug\TCP.vshost.exe.config

     文件        490  2018-04-12 07:35  TCP\TCP\bin\Debug\TCP.vshost.exe.manifest

     文件     189440  2019-01-09 17:10  TCP\TCP\bin\Release\TCP.exe

     文件        189  2019-01-08 14:42  TCP\TCP\bin\Release\TCP.exe.config

     文件      26112  2019-01-09 17:10  TCP\TCP\bin\Release\TCP.pdb

     文件      22984  2019-01-09 17:10  TCP\TCP\bin\Release\TCP.vshost.exe

     文件        189  2019-01-08 14:42  TCP\TCP\bin\Release\TCP.vshost.exe.config

     文件        490  2018-04-12 07:35  TCP\TCP\bin\Release\TCP.vshost.exe.manifest

     文件       4286  2019-01-09 16:22  TCP\TCP\favicon-20190109042104268.ico

     文件       9991  2019-01-09 17:49  TCP\TCP\Form1.cs

     文件       5467  2019-01-09 17:49  TCP\TCP\Form1.Designer.cs

     文件       5817  2019-01-09 17:49  TCP\TCP\Form1.resx

     文件       1476  2019-01-09 08:32  TCP\TCP\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6999  2019-01-09 16:22  TCP\TCP\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        402  2019-01-09 17:49  TCP\TCP\obj\Debug\TCP.csproj.FileListAbsolute.txt

     文件       1028  2019-01-09 17:49  TCP\TCP\obj\Debug\TCP.csproj.GenerateResource.Cache

     文件       2231  2019-01-09 08:33  TCP\TCP\obj\Debug\TCP.csprojResolveAssemblyReference.cache

     文件     190464  2019-01-09 17:49  TCP\TCP\obj\Debug\TCP.exe

     文件        180  2019-01-09 17:49  TCP\TCP\obj\Debug\TCP.Form1.resources

     文件      28160  2019-01-09 17:49  TCP\TCP\obj\Debug\TCP.pdb

     文件     171462  2019-01-09 16:22  TCP\TCP\obj\Debug\TCP.Properties.Resources.resources

     文件          0  2019-01-08 14:42  TCP\TCP\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-01-08 14:42  TCP\TCP\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-01-08 14:42  TCP\TCP\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       4608  2019-01-09 13:24  TCP\TCP\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

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

评论

共有 条评论