Exemplo n.º 1
0
        public void Resolve(string node, string service, Action <UvArgs <IPEndPoint[]> > callback = null)
        {
            var hints    = addrinfo.CreateHints();
            var hintsPtr = this.Loop.Allocs.Alloc(Marshal.SizeOf(typeof(addrinfo)));

            Marshal.StructureToPtr(hints, hintsPtr, fDeleteOld: false);

            try
            {
                _resolveReq = this.Loop.Requests.Create(uv_req_type.UV_GETADDRINFO);
                CheckError(Uvi.uv_getaddrinfo(this.Loop.Handle, _resolveReq, _resolveDelegate, node, service, hintsPtr));
                this.Status      = HandleStatus.Resolving;
                _resolveCallback = new UvEndPointsCallback(this, callback);
            }
            catch (Exception)
            {
                this.Loop.Requests.Delete(_resolveReq);
                _connectCallback = null;
                throw;
            }
            finally
            {
                this.Loop.Allocs.Free(hintsPtr);
            }
        }