主要代码如下,大家帮我看看:
服务端:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace SocketProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSend_Click(object sender, EventArgs e)
{
string strmsg = this.txtMsgSend.Text.Trim();
byte[] arrary=Encoding.UTF8.GetBytes(strmsg);
socketwathc.Send(arrary);
ShowMsg("发送了数据:" + strmsg);
}
}
}
客户端:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace ClientProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();