示例#1
0
 /// <summary>
 /// 触发数据发送完毕的事件
 /// </summary>
 /// <param name="state"></param>
 private void RaiseCompletedSend(AsyncSocketUDPState state)
 {
     if (CompletedSend != null)
     {
         CompletedSend(this, new AsyncSocketUDPEventArgs(state));
     }
 }
示例#2
0
 /// <summary>
 /// 触发发送数据前的事件
 /// </summary>
 /// <param name="state"></param>
 private void RaisePrepareSend(AsyncSocketUDPState state)
 {
     if (PrepareSend != null)
     {
         PrepareSend(this, new AsyncSocketUDPEventArgs(state));
     }
 }
示例#3
0
 private void RaiseDataReceived(AsyncSocketUDPState state)
 {
     if (DataReceived != null)
     {
         DataReceived(this, new AsyncSocketUDPEventArgs(state));
     }
 }
示例#4
0
        /// <summary>
        /// 异步Socket UDP服务器
        /// </summary>
        /// <param name="localIPAddress">监听的IP地址</param>
        /// <param name="listenPort">监听的端口</param>
        /// <param name="maxClient">最大客户端数量</param>
        public AsyncSocketUDPServer(IPAddress localIPAddress, int listenPort)
        {
            this.Address  = localIPAddress;
            this.Port     = listenPort;
            this.Encoding = Encoding.Default;

            _serverSock = new Socket(localIPAddress.AddressFamily, SocketType.Dgram, ProtocolType.Udp);

            so        = new AsyncSocketUDPState();
            clientMsg = new List <AsyncSocketClientMsg> {
            };
        }
 public AsyncSocketUDPEventArgs(string msg, AsyncSocketUDPState state)
 {
     this._msg   = msg;
     this._state = state;
     IsHandled   = false;
 }
 public AsyncSocketUDPEventArgs(AsyncSocketUDPState state)
 {
     this._state = state;
     IsHandled   = false;
 }