[問題] udp server
為什麼執行時無法顯示表單
表單單純接收client資料並自動回傳 現在client端可以收到server回傳東西
以下是程式碼
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System; //For Console, Int32,ArgumentException,Environment
using System.Net; //IPEndPoint
using System.Net.Sockets; //For UdpClient,SocketException
namespace WindowsApplication1
{
public partial class udp_test : Form
{
public udp_test()
{
InitializeComponent();
Open_udp();
}
public void Open_udp()
{
int serverPort = 6666;
UdpClient client = null;
try
{
client = new UdpClient(serverPort);
}
catch (SocketException se) {
ShowBox.AppendText(se.ErrorCode + ":" + se.Message);
Environment.Exit(se.ErrorCode);
}
IPEndPoint reIPEndPoint = new IPEndPoint(IPAddress.Any, 0);
for (; ; )
{
try
{
byte[] byteBuffer = client.Receive(ref reIPEndPoint);
ShowBox.AppendText("handling client at " + reIPEndPoint +
"-" + "\n");
ShowBox.AppendText(Encoding.ASCII.GetString(byteBuffer, 0,
byt\eBuffer.Length) + "\n");
client.Send(byteBuffer, byteBuffer.Length, reIPEndPoint);
ShowBox.AppendText("{0}byte"+ byteBuffer.Length);
}
catch (SocketException se) {
ShowBox.AppendText(se.ErrorCode + ":" + se.Message);
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.229.174.22
→
06/15 15:52, , 1F
06/15 15:52, 1F
→
06/15 16:30, , 2F
06/15 16:30, 2F
→
06/15 16:31, , 3F
06/15 16:31, 3F
→
06/15 16:46, , 4F
06/15 16:46, 4F
推
06/15 22:57, , 5F
06/15 22:57, 5F
→
06/27 08:33, , 6F
06/27 08:33, 6F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
1
6
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章