public override object GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName) { if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) { return((object)this.GetLingerOpt()); } if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { return((object)this.GetMulticastOpt(optionName)); } if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { return((object)this.GetIPv6MulticastOpt(optionName)); } int optionValue = 0; int optionLength = 4; if (UnsafeMethods.getsockopt(Handle, optionLevel, optionName, out optionValue, ref optionLength) != SocketError.SocketError) { return(optionValue); } else { throw new SocketException(); } }
public override void GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) { int optionLength = optionValue != null ? optionValue.Length : 0; if (UnsafeMethods.getsockopt(this.Handle, optionLevel, optionName, optionValue, ref optionLength) == SocketError.SocketError) { throw new SocketException(); } }
public override byte[] GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength) { byte[] optionValue = new byte[optionLength]; int optionLength1 = optionLength; if (UnsafeMethods.getsockopt(Handle, optionLevel, optionName, optionValue, ref optionLength1) != SocketError.SocketError) { if (optionLength != optionLength1) { byte[] numArray = new byte[optionLength1]; Buffer.BlockCopy(optionValue, 0, numArray, 0, optionLength1); optionValue = numArray; } return(optionValue); } else { throw new SocketException(); } }