private void btn_Send_Click(object sender, EventArgs e)
{
//Thread thr = new Thread(new Program().btn_Send_Click);
//thr.Start(0);
port = 60000;
host = "127.0.0.1";
ip = IPAddress.Parse(host);
ipe = new IPEndPoint(ip, port);
c = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
c.Connect(ipe);
string sendstr = txt_Show1.Text;
Byte[] bs = Encoding.ASCII.GetBytes(sendstr);
c.Send(bs, bs.Length, 0);
string recvStr = "";
byte[] recvBytes = new byte[1024];
int bytes;
bytes = c.Receive(recvBytes, recvBytes.Length, 0);
recvStr += Encoding.ASCII.GetString(recvBytes, 0, bytes);
txt_Show.Text = recvStr;用tcp测试工具测试,设置断点就能正常发送字符过去,没设置断点就不能显示,请大侠帮忙
{
//Thread thr = new Thread(new Program().btn_Send_Click);
//thr.Start(0);
port = 60000;
host = "127.0.0.1";
ip = IPAddress.Parse(host);
ipe = new IPEndPoint(ip, port);
c = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
c.Connect(ipe);
string sendstr = txt_Show1.Text;
Byte[] bs = Encoding.ASCII.GetBytes(sendstr);
c.Send(bs, bs.Length, 0);
string recvStr = "";
byte[] recvBytes = new byte[1024];
int bytes;
bytes = c.Receive(recvBytes, recvBytes.Length, 0);
recvStr += Encoding.ASCII.GetString(recvBytes, 0, bytes);
txt_Show.Text = recvStr;用tcp测试工具测试,设置断点就能正常发送字符过去,没设置断点就不能显示,请大侠帮忙
解决方案 »
- 关于调用32位动态链接库的问题
- C#跨进程通信问题
- 如何用C#实现类似于photoshop的软件界面?
- Infragistics.Win.UltraWinEditors有人用过没有?怎么用?里面都有什么样的控件?
- c#如何实现拖动文件
- 我想把给datagrid的数据源datatable(从数据库取来)添加的列放到第一列怎么做?
- C# 多线程问题 如何防止线程重复运行
- 关于CLICKONCE发布问题!!
- 菜鸟的问题---熟悉C#和XML的大人过来
- 一个奇怪的问题
- VS2010中,采用TFS,每次获取最新后,工程浏览器中的锁都回丢失?
- C# 2010 and the .NET 4 Platform, 5th Edition
解决方法:创建一个新的线程Threah,存放bytes = c.Receive(recvBytes, recvBytes.Length, 0);