+2009-04-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * EndPoint.cs: Throw NotImplementedException instead of
+ NotSupportedException
+ * IPEndPoint.cs: Fix some validations.
+
2009-04-21 Gonzalo Paniagua Javier <gonzalo@novell.com>
* WebConnection.cs:
public abstract class EndPoint {
// NB: These methods really do nothing but throw
- // NotSupportedException
+ // NotImplementedException
public virtual AddressFamily AddressFamily {
- get {
- throw new NotSupportedException();
- }
+ get { throw NotImplemented (); }
}
public virtual EndPoint Create (SocketAddress address)
{
- throw new NotSupportedException();
+ throw NotImplemented ();
}
public virtual SocketAddress Serialize ()
{
- throw new NotSupportedException();
+ throw NotImplemented ();
}
protected EndPoint ()
{
}
+
+ static Exception NotImplemented ()
+ {
+ // hide the "normal" NotImplementedException from corcompare-like tools
+ return new NotImplementedException ();
+ }
}
}
public IPEndPoint (IPAddress address, int port)
{
if (address == null)
- throw new ArgumentNullException ("Value cannot be null");
+ throw new ArgumentNullException ("address");
Address = address;
Port = port;
}
- public IPEndPoint (long iaddr, int port) : this (new IPAddress (iaddr), port)
+ public IPEndPoint (long iaddr, int port)
{
+ Address = new IPAddress (iaddr);
+ Port = port;
}
public IPAddress Address {
// bytes 2 and 3 store the port, the rest
// stores the address
- public override EndPoint Create(SocketAddress sockaddr) {
- int size=sockaddr.Size;
-
- // LAMESPEC: no mention of what to do if
- // sockaddr is bogus
- if(size<8) {
- // absolute minimum amount needed for
- // an address family, buffer size,
- // port and address
- return(null);
- }
+ public override EndPoint Create (SocketAddress socketAddress)
+ {
+ if (socketAddress == null)
+ throw new ArgumentNullException ("socketAddress");
+
+ if (socketAddress.Family != AddressFamily)
+ throw new ArgumentException ("socketAddress");
+ SocketAddress sockaddr = socketAddress;
+ int size =sockaddr.Size;
AddressFamily family = sockaddr.Family;
int port;