close() public méthode

public close ( ) : void
Résultat void
        void _startSend()
        {
            int sendSize = Interlocked.Add(ref _wpos, 0) - _spos;
            int t_spos   = _spos % _buffer.Length;

            if (t_spos == 0)
            {
                t_spos = sendSize;
            }

            if (sendSize > _buffer.Length - t_spos)
            {
                sendSize = _buffer.Length - t_spos;
            }

            try
            {
                _networkInterface.sock().BeginSend(_buffer, _spos % _buffer.Length, sendSize, 0,
                                                   new AsyncCallback(_onSent), this);
            }
            catch (Exception e)
            {
                Dbg.ERROR_MSG("PacketSender::startSend(): is err: " + e.ToString());
                _networkInterface.close();
            }
        }
        public void startRecv()
        {
            // 必须有空间可写,否则我们阻塞在线程中直到有空间为止
            int first = 0;
            int space = _free();

            while (space == 0)
            {
                if (first > 0)
                {
                    Dbg.WARNING_MSG("PacketReceiver::startRecv(): waiting for space! retries=" + first);
                    System.Threading.Thread.Sleep(5);
                }

                first += 1;
                space  = _free();
            }

            try
            {
                _networkInterface.sock().BeginReceive(_buffer, _wpos, space, 0,
                                                      new AsyncCallback(_onRecv), this);
            }
            catch (Exception e)
            {
                Dbg.ERROR_MSG("PacketReceiver::startRecv(): call ReceiveAsync() is err: " + e.ToString());
                _networkInterface.close();
            }
        }
Exemple #3
0
 static int close(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         obj.close();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 public void _closeNetwork(NetworkInterface networkInterface)
 {
     networkInterface.close();
 }