public static void StructureToPtr(CsAddrInfoSafe input, IntPtr target)
                {
                    CsAddrInfoNative native;
                    native.iProtocol = input.iProtocol;
                    native.iSocketType = input.iSocketType;
                    native.LocalAddr.iSockaddrLength = input.LocalAddr.iSockaddrLength;
                    native.LocalAddr.lpSockAddr = input.LocalAddr.lpSockAddr;
                    native.RemoteAddr.iSockaddrLength = input.RemoteAddr.iSockaddrLength;
                    native.RemoteAddr.lpSockAddr = input.RemoteAddr.lpSockAddr;

                    Marshal.StructureToPtr(native, target, false);
                }
                public static CsAddrInfoSafe[] FromAddresses(CsAddrInfo[] addresses)
                {
                    CsAddrInfoSafe addr;
                    CsAddrInfoSafe[] result = null;
                    if (addresses == null || addresses.Length == 0)
                        return null;

                    result = new CsAddrInfoSafe[addresses.Length];
                    int i = 0;
                    foreach (CsAddrInfo info in addresses)
                    {
                        addr = new CsAddrInfoSafe();
                        addr.LocalAddr = SOCKET_ADDRESS_SAFE.SocketAddressFromIPEndPoint(info.LocalAddr);
                        addr.RemoteAddr = SOCKET_ADDRESS_SAFE.SocketAddressFromIPEndPoint(info.RemoteAddr);
                        addr.iProtocol = info.iProtocol;
                        addr.iSocketType = info.iSocketType;
                        result[i++] = addr;
                    }
                    return result;
                }