Пример #1
0
    /**
     *  异步结束连接
     */
    public int EndConnect(IAsyncResult iar)
    {
        DelegateForConnect delCon = (iar as AsyncResult).AsyncDelegate as  DelegateForConnect;
        int result = -1;

        try {
            result = delCon.EndInvoke(iar);
        }
        catch (Exception ex) {
            Debug.LogError(ex);
        }
        return(result);
    }
Пример #2
0
    /**
     *  异步开始连接
     */
    public IAsyncResult  BeginConnect(string domain, int port, int netWork, int spType, int timeOut, AsyncCallback callback, System.Object state)
    {
        if (domain == null || domain.Length <= 0)
        {
            throw new ArgumentException("The length of the domain  should not be null");
        }
        if (port <= 0 || port > 65535)
        {
            throw new ArgumentOutOfRangeException("port", "Must be > 0 and < 65536");
        }
        DelegateForConnect delCon = new  DelegateForConnect(Connect);

        return(delCon.BeginInvoke(domain, port, netWork, spType, timeOut, callback, state));
    }