internal static void StartRead(SocketObject socketObj)
        {
            RemoteSocketObject remoteSocketObj = new RemoteSocketObject();

            remoteSocketObj.socket   = socketObj.socket;            // 除了TCP服务器,都是这样
            remoteSocketObj.Parent   = socketObj;
            remoteSocketObj.remoteEP = socketObj.remoteIpEP;
            socketObj.remoteSocketObjs.Add(remoteSocketObj);
            remoteSocketObj.socket.BeginReceive(remoteSocketObj.buffer, 0, RemoteSocketObject.BufferSize, 0,
                                                new AsyncCallback(AsynchronousSocketListener.readCallback), remoteSocketObj);
        }
Exemplo n.º 2
0
 protected override void DisconnectSocketObj(int index2)
 {
     try {
         SocketObject tObj = (SocketObject)socketObjs[index2];
         if (tObj.socket.Connected)
         {
             tObj.socket.Shutdown(SocketShutdown.Both);
             tObj.socket.Disconnect(true);
         }
         tObj.remoteSocketObjs.Clear();
         tObj.socket.Close();
     } catch (Exception) { }
 }
Exemplo n.º 3
0
        // 删除2级节点
        protected virtual bool DelSocketObj(int index2)
        {
            try {
                DelAllRemoteSocketObj(index2);
                DisconnectSocketObj(index2);
                SocketObject tObj = (SocketObject)socketObjs[index2];
                tObj.socket.Close();
            } catch (Exception) {
                return(false);
            } finally {
                socketObjs.RemoveAt(index2);
            }

            return(true);
        }
Exemplo n.º 4
0
 private void RecvMsg(object sender, RecvEventArgs e)
 {
     if (!e.IsErr)
     {
         if (e.RemoteSocketObj.Parent is UdpServerSocketObject)
         {
             SocketObject obj        = (SocketObject)e.RemoteSocketObj.Parent;
             bool         isSelected = false;
             if (socketModels[index1] == (SocketModel)obj.Parent && obj.Parent.Children[index2] == obj)
             {
                 isSelected = true;
             }
             ((SocketModel)obj.Parent).UpdateSubTreeView(obj, isSelected);
         }
         Dispatcher.Invoke(Refresh);
         Dispatcher.Invoke(RefreshTree);
     }
     else
     {
         ObjNeedRm = e.RemoteSocketObj;
         Dispatcher.Invoke(RemoveRemoteItem);
     }
 }
 public AcceptEventArgs(SocketObject socketObj)
 {
     this.socketObj = socketObj;
 }