Tuesday, January 19, 2010

Hi,
I am writing this as a feedback due to an error in the code posted in your website. The part called Creating Protocols Header Definition Class (C#) Part a. This part has a class called SockaddrConvert. Find the code below as it appears on your website:

class SockaddrConvert {
///
/// This routine converts an IPEndPoint into a byte array that represents the
/// underlying sockaddr structure of the correct type. Currently this routine
/// supports only IPv4 and IPv6 socket address structures.
///

/// IPEndPoint to convert to a binary form
/// Binary array of the serialized socket address structure

static public byte[] GetSockaddrBytes(IPEndPoint endPoint)
{
SocketAddress socketAddrermal" style="text-autospace:none"> unpackedPort = BitConverter.ToUInt16(sockaddrBytes, 2);

Array.Copy(sockaddrBytes, 8, addressBytes, 0, 16);
unpackedAddress = new IPAddress(addressBytes);
unpackedEndpoint = new IPEndPoint(unpackedAddress, unpackedPort);
}
else
{
Console.WriteLine("GetEndPoint: Unknown address family: {0}", addressFamily);
}

return unpackedEndpoint;
}
}


Fatos Peci

------------------------------------------------
Thank you very much. The error happened when uploading the file. Please find the original source code in the Download page. It looks like the webmaster has corrected the error.
Take note that all those code examples just for learning, it is not for any 'production'. All are 'loose' codes, used in one of the class taught by one of the instructors. The following is the correct one.