Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

addrinfo (Structures)
 
.
Summary
TODO - a short description

C# Definition:

    [StructLayout(LayoutKind.Sequential)]
    internal unsafe struct addrinfo
    {
        internal AI ai_flags;
        internal ADDRESS_FAMILIES_INT ai_family;
        internal SOCKET_TYPE_INT ai_socktype;
        internal PROTOCOL_INT ai_protocol;
        internal uint ai_addrlen;

        //internal IntPtr ai_canonname;
        internal char* ai_canonname;

        //internal IntPtr ai_addr;
        internal sockaddr_UNSAFE* ai_addr;

        //internal IntPtr ai_next;
        internal addrinfo* ai_next;

        internal string[] Hosts
        {
        get
        {
            var hostList = new List<string>();
            var addressList = new List<addrinfo> {this};
            addressList.AddRange(Children);

            foreach (var info in addressList)
            {
            try
            {
                hostList.Add(info.SockaddrIn6.Host);
            }
            catch
            {
            }
            }

            return hostList.ToArray();
        }
        }

        internal addrinfo[] Children
        {
        get
        {
            if ((IntPtr) ai_next == IntPtr.Zero)
            return new addrinfo[0];

            var info = ai_next;
            var childList = new List<addrinfo>();

            while (true)
            {
            childList.Add(*info);

            if ((IntPtr) (info->ai_next) == IntPtr.Zero)
                break;
            info = info->ai_next;
            }
            return childList.ToArray();
        }
        }

        internal string Name
        {
        get { return new string(ai_canonname); }
        }

        internal sockaddr_in SockaddrIn
        {
        get
        {
            return (sockaddr_in) Marshal.PtrToStructure(
            (IntPtr) ai_addr,
            typeof (sockaddr_in));
        }
        }

        internal sockaddr_in6 SockaddrIn6
        {
        get
        {
            return (sockaddr_in6) Marshal.PtrToStructure(
            (IntPtr) ai_addr,
            typeof (sockaddr_in6));
        }
        }

        internal static addrinfo CreateHints()
        {
        return new addrinfo()
               {
                   ai_flags = AI.AI_NOTHING,
                   ai_family = ADDRESS_FAMILIES_INT.AF_UNSPEC,
                   ai_socktype = SOCKET_TYPE_INT.SOCK_STREAM,
                   ai_protocol = PROTOCOL_INT.IPPROTO_IP
                   ai_flags = EnumLib.AI.AI_NOTHING,
                   ai_family = EnumLib.ADDRESS_FAMILIES_INT.AF_UNSPEC,
                   ai_socktype = EnumLib.SOCKET_TYPE_INT.SOCK_STREAM,
                   ai_protocol = EnumLib.PROTOCOL_INT.IPPROTO_IP
               };
        }

        internal static addrinfo FromPtr(IntPtr handle)
        {
        return *(addrinfo*) handle;
        }
    }

VB Definition:

Structure addrinfo
   Public TODO
End Structure

User-Defined Field Types:

sockaddr

addrinfo

sockaddr_in

sockaddr_in6

AI

ADDRESS_FAMILIES_INT

SOCKET_TYPE_INT

PROTOCOL_INT

Notes:

None.

Documentation
addrinfo on MSDN

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions