服務器用來接收文件,不停的監聽端口,有發送文件就馬上開始接收文件
服務端代碼:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
-
-
- using System.Net;
- using System.Threading;
- using System.Net.Sockets;
-
- using System.IO;
-
- namespace TestSocketServerHSTF
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
-
-
- //不顯示出dataGridView1的最後一行空白
- dataGridView1.AllowUserToAddRows = false;
- }
-
-
- #region 定義變量
-
-
- #endregion
-
-
-
- #region 進入窗體即啟動服務
-
- private void Form1_Load(object sender, EventArgs e)
- {
- //開啟接收線程
- Thread TempThread = new Thread(new ThreadStart(this.StartReceive));
- TempThread.Start();
- }
-
-
- #endregion
-
-
-
-