日期:2014-05-17 浏览次数:20784 次
public class SocketListener
{
public event DltMessage EvtMessageReceived;// 接收到消息后事件
private Thread work = null;
private Socket socket = null;
private int port = 11111;
/// <summary>
/// 开始监听
/// </summary>
public void StartListen()
{
work = new Thread(new ThreadStart(Start));
work.IsBackground = true;
work.Start();
}
public void Start()
{
try
{
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, port);
using (receiveClient = new UdpClient(remoteEP))
{
while (true)
{