本文整理汇总了C#中System.Net.SocketAddress.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SocketAddress.GetType方法的具体用法?C# SocketAddress.GetType怎么用?C# SocketAddress.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.SocketAddress
的用法示例。
在下文中一共展示了SocketAddress.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public override EndPoint Create(SocketAddress socketAddress)
{
if (socketAddress.Family != this.AddressFamily)
{
throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", new object[] { socketAddress.Family.ToString(), base.GetType().FullName, this.AddressFamily.ToString() }), "socketAddress");
}
if (socketAddress.Size < 8)
{
throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", new object[] { socketAddress.GetType().FullName, base.GetType().FullName }), "socketAddress");
}
if (this.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
{
byte[] address = new byte[0x10];
for (int i = 0; i < address.Length; i++)
{
address[i] = socketAddress[i + 8];
}
int num2 = ((socketAddress[2] << 8) & 0xff00) | socketAddress[3];
long scopeid = (((socketAddress[0x1b] << 0x18) + (socketAddress[0x1a] << 0x10)) + (socketAddress[0x19] << 8)) + socketAddress[0x18];
return new IPEndPoint(new IPAddress(address, scopeid), num2);
}
int port = ((socketAddress[2] << 8) & 0xff00) | socketAddress[3];
return new IPEndPoint(((((socketAddress[4] & 0xff) | ((socketAddress[5] << 8) & 0xff00)) | ((socketAddress[6] << 0x10) & 0xff0000)) | (socketAddress[7] << 0x18)) & ((long) 0xffffffffL), port);
}
示例2: Create
public override EndPoint Create(SocketAddress socketAddress)
{
// Validate SocketAddress
if (socketAddress.Family != this.AddressFamily)
{
throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), "socketAddress");
}
if (socketAddress.Size < 8)
{
throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), "socketAddress");
}
return socketAddress.GetIPEndPoint();
}
示例3: Create
/// <include file='doc\IPEndPoint.uex' path='docs/doc[@for="IPEndPoint.Create"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override EndPoint Create(SocketAddress socketAddress) {
//
// validate SocketAddress
//
if (socketAddress.Family != this.AddressFamily) {
throw new ArgumentException(SR.GetString(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()));
}
if (socketAddress.Size<8) {
throw new ArgumentException(SR.GetString(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName));
}
//
// strip out of SocketAddress information on the EndPoint
//
int port =
((int)socketAddress[2]<<8) |
((int)socketAddress[3]);
long address = (long)(
((int)socketAddress[4] ) |
((int)socketAddress[5]<<8 ) |
((int)socketAddress[6]<<16) |
((int)socketAddress[7]<<24)
) & 0x00000000FFFFFFFF;
IPEndPoint created = new IPEndPoint(address, port);
GlobalLog.Print("IPEndPoint::Create: " + this.ToString() + " -> " + created.ToString() );
//
// return it
//
return created;
}
示例4: Create
/// <summary>
/// Creates an endpoint from a socket address.
/// </summary>
///
/// <returns>
/// An <see cref="T:System.Net.EndPoint"/> instance using the specified socket address.
/// </returns>
/// <param name="socketAddress">The <see cref="T:System.Net.SocketAddress"/> to use for the endpoint. </param><exception cref="T:System.ArgumentException">The AddressFamily of <paramref name="socketAddress"/> is not equal to the AddressFamily of the current instance.-or- <paramref name="socketAddress"/>.Size < 8. </exception><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet>
public override EndPoint Create(SocketAddress socketAddress)
{
if (socketAddress.Family != this.AddressFamily)
{
throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", (object) ((object) socketAddress.Family).ToString(), (object) this.GetType().FullName, (object) ((object) this.AddressFamily).ToString()), "socketAddress");
}
else
{
if (socketAddress.Size >= 8)
return (EndPoint) socketAddress.GetIPEndPoint();
throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", (object) socketAddress.GetType().FullName, (object) this.GetType().FullName), "socketAddress");
}
}
示例5: Create
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override EndPoint Create(SocketAddress socketAddress) {
//
// validate SocketAddress
//
if (socketAddress.Family != this.AddressFamily) {
throw new ArgumentException(SR.GetString(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), "socketAddress");
}
if (socketAddress.Size<8) {
throw new ArgumentException(SR.GetString(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), "socketAddress");
}
if ( this.AddressFamily == AddressFamily.InterNetworkV6 ) {
//
// IPv6 Changes: Extract the IPv6 Address information from the socket address
//
byte[] addr = new byte[IPAddress.IPv6AddressBytes];
for (int i = 0; i < addr.Length; i++)
{
addr[i] = socketAddress[i + 8];
}
//
// Port
//
int port = (int)((socketAddress[2]<<8 & 0xFF00) | (socketAddress[3]));
//
// Scope
//
long scope = (long)((socketAddress[27] << 24) +
(socketAddress[26] << 16) +
(socketAddress[25] << 8 ) +
(socketAddress[24]));
IPEndPoint created = new IPEndPoint(new IPAddress(addr,scope),port);
GlobalLog.Print("IPEndPoint::Create IPv6: " + this.ToString() + " -> " + created.ToString() );
return created;
}
else
{
//
// strip out of SocketAddress information on the EndPoint
//
int port = (int)(
(socketAddress[2]<<8 & 0xFF00) |
(socketAddress[3])
);
long address = (long)(
(socketAddress[4] & 0x000000FF) |
(socketAddress[5]<<8 & 0x0000FF00) |
(socketAddress[6]<<16 & 0x00FF0000) |
(socketAddress[7]<<24)
) & 0x00000000FFFFFFFF;
IPEndPoint created = new IPEndPoint(address, port);
GlobalLog.Print("IPEndPoint::Create: " + this.ToString() + " -> " + created.ToString() );
//
// return it
//
return created;
}
}