• 大小: 239KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-20
  • 语言: C#
  • 标签:

资源简介

c#局域网通信win10能用最新版本vS2017 根据飞鸽传书修改保留主要功能 能正常通信 传输文件

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Cont_ip
{
    public class Protocol
    {
        //private IPAddress recIP = null;
        //private string SendFileName = ““;

        //private void btnSendTo_Click(object sender EventArgs e)
        //{
        //    int RemotePort = 9999;
        //    if (recIP == null)
        //        return;
        //    else
        //    {
        //        try
        //        {
        //            IPEndPoint iep = new IPEndPoint(recIP RemotePort);
        //            Socket socket1 = new Socket(AddressFamily.InterNetwork SocketType.Stream ProtocolType.Tcp);

        //            socket1.Connect(iep);
        //            NetworkStream stream = new NetworkStream(socket1);
        //            //string control = “Message“;
        //            //byte[] newbyte = Encoding.UTF8.GetBytes(control.ToCharArray());
        //            //socket1.Send(newbyte newbyte.Length 0);
        //            //byte[] msgsize = new byte[4];
        //            //byte[] msgbyte = Encoding.UTF8.GetBytes(rtbSend.Text.Trim());
        //            //msgsize = BitConverter.GetBytes(msgbyte.Length);
        //            //socket1.Send(msgsize msgsize.Length 0);
        //            //socket1.Send(msgbyte msgbyte.Length 0);

        //            Send_Message(socket1 “Message“ rtbSend.Text.Trim());

        //            control = “Require“;
        //            byte[] bytes = Encoding.UTF8.GetBytes(control.ToCharArray());
        //            socket1.Send(bytes bytes.Length 0);
        //            byte[] fileNameSize = new byte[4];
        //            byte[] sendfileName = Encoding.UTF8.GetBytes(Path.GetFileName(SendFileName).ToCharArray());
        //            fileNameSize = BitConverter.GetBytes(sendfileName.Length);
        //            socket1.Send(fileNameSize fileNameSize.Length 0);
        //            socket1.Send(sendfileName sendfileName.Length 0);

        //            Task.Factory.StartNew(() => ReciveFrom(stream));
        //            this.btnFileName.Text = ““;
        //            this.rtbSend.Clear();
        //            this.btnFileName.Visible = false;
        //        }
        //        catch
        //        {
        //            MessageBox.Show(“fs“);
        //        }
        //    }
        //}


        public void Send_Data(Socket socketstring control string Message)
        {
            byte[] newbyte = Encoding.UTF8.GetBytes(control.ToCharArray());
            byte[] msgbyte = Encoding.UTF8.GetBytes(Message.ToCharArray());
            byte[] msgsize = BitConverter.GetBytes(msgbyte.Length);

            socket.Send(newbyte newbyte.Length 0);//发送命令
            socket.Send(msgsize msgsize.Length 0);//消息名字

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-20 15:56  FastPass\
     目录           0  2018-01-22 08:57  FastPass\FastPass\
     目录           0  2018-01-20 15:56  FastPass\FastPass\.vs\
     目录           0  2018-01-20 15:56  FastPass\FastPass\.vs\FastPass\
     目录           0  2018-01-20 15:56  FastPass\FastPass\.vs\FastPass\v15\
     文件       62976  2018-02-06 17:31  FastPass\FastPass\.vs\FastPass\v15\.suo
     目录           0  2018-01-20 15:56  FastPass\FastPass\.vs\FastPass\v15\Server\
     目录           0  2018-02-06 17:31  FastPass\FastPass\.vs\FastPass\v15\Server\sqlite3\
     文件           0  2018-01-20 15:56  FastPass\FastPass\.vs\FastPass\v15\Server\sqlite3\db.lock
     文件      593920  2018-02-06 17:31  FastPass\FastPass\.vs\FastPass\v15\Server\sqlite3\storage.ide
     目录           0  2018-01-22 13:58  FastPass\FastPass\Cont_ip\
     文件        2207  2018-01-22 10:01  FastPass\FastPass\Cont_ip\Cont_ip.csproj
     目录           0  2018-01-22 08:57  FastPass\FastPass\Cont_ip\Properties\
     文件        1303  2018-01-22 08:57  FastPass\FastPass\Cont_ip\Properties\AssemblyInfo.cs
     目录           0  2018-01-22 08:58  FastPass\FastPass\Cont_ip\bin\
     目录           0  2018-01-22 13:58  FastPass\FastPass\Cont_ip\bin\Debug\
     文件        4608  2018-01-22 13:58  FastPass\FastPass\Cont_ip\bin\Debug\Cont_ip.dll
     文件       11776  2018-01-22 13:58  FastPass\FastPass\Cont_ip\bin\Debug\Cont_ip.pdb
     目录           0  2018-03-01 19:59  FastPass\FastPass\Cont_ip\bin\Release\
     目录           0  2018-01-22 08:57  FastPass\FastPass\Cont_ip\obj\
     目录           0  2018-01-22 13:58  FastPass\FastPass\Cont_ip\obj\Debug\
     文件          42  2018-01-22 13:58  FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.csproj.CoreCompileInputs.cache
     文件         287  2018-01-22 13:58  FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.csproj.FileListAbsolute.txt
     文件        4608  2018-01-22 13:58  FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.dll
     文件       11776  2018-01-22 13:58  FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.pdb
     文件        6783  2018-01-22 09:00  FastPass\FastPass\Cont_ip\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2018-03-01 19:59  FastPass\FastPass\Cont_ip\obj\Debug\TempPE\
     文件           0  2018-01-22 08:57  FastPass\FastPass\Cont_ip\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2018-01-22 08:57  FastPass\FastPass\Cont_ip\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2018-01-22 08:57  FastPass\FastPass\Cont_ip\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     文件        3355  2018-01-22 13:58  FastPass\FastPass\Cont_ip\protocol .cs
............此处省略38个文件信息

评论

共有 条评论

相关资源