C# Socket 服务器客户端通信(一)
客户端
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;
//1.引用3个
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace TCP_client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
}
//TCP客户端程序
#region
//1.2声明一个变量,判断TCP是否已经连接
public bool isConnecting;
//1.3声明一个socket实例;
public Socket socket_demo;
//1.4声明2个字符串,存储服务器IP和端口
public string sercer_IP; public int server_Port;