in_addr in iphlp.cs

Home Forums Discussions Support in_addr in iphlp.cs

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5280
    bakhtiar
    Participant

      Hello;

      Could anyone help how to define in_addr in C#, I could not find this structure in iphlp.cs?

      Regards

      #6792
      bakhtiar
      Participant

        Hi;

        As the in_addr struct is not availabile in iphlp.cs, this is for those who wants to use this struct in c#.

        [StructLayout(LayoutKind.Auto)]

        public struct sb
        {
        public byte s_b1, s_b2, s_b3, s_b4;
        }

        [StructLayout(LayoutKind.Auto)]

        public struct sw
        {
        public ushort s_w1, s_w2;
        }

        [StructLayout(LayoutKind.Explicit, Size = 4)]
        public struct in_addr
        {
        [FieldOffset(0)]
        public sb S_un_b;
        [FieldOffset(0)]
        public sw S_un_w;
        [FieldOffset(0)]
        public uint S_addr;
        }

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.