//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public Object getOption(int opt) throws SocketException public override Object GetOption(int opt) { if (ClosedOrPending) { throw new SocketException("Socket Closed"); } if (opt == SocketOptions_Fields.SO_BINDADDR) { if (Fd != null && Fd1 != null) { /* must be unbound or else bound to anyLocal */ return(AnyLocalBoundAddr); } InetAddressContainer @in = new InetAddressContainer(); SocketGetOption(opt, @in); return(@in.Addr); } else if (opt == SocketOptions_Fields.SO_REUSEADDR && ExclusiveBind) { // SO_REUSEADDR emulated when using exclusive bind return(IsReuseAddress); } else { return(base.GetOption(opt)); } }
internal static extern void localAddress(int fd, InetAddressContainer @in);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public Object getOption(int opt) throws SocketException public override Object GetOption(int opt) { if (ClosedOrPending) { throw new SocketException("Socket Closed"); } if (opt == SocketOptions_Fields.SO_TIMEOUT) { return(new Integer(Timeout_Renamed)); } int ret = 0; /* * The native socketGetOption() knows about 3 options. * The 32 bit value it returns will be interpreted according * to what we're asking. A return of -1 means it understands * the option but its turned off. It will raise a SocketException * if "opt" isn't one it understands. */ switch (opt) { case SocketOptions_Fields.TCP_NODELAY: ret = SocketGetOption(opt, null); return(Convert.ToBoolean(ret != -1)); case SocketOptions_Fields.SO_OOBINLINE: ret = SocketGetOption(opt, null); return(Convert.ToBoolean(ret != -1)); case SocketOptions_Fields.SO_LINGER: ret = SocketGetOption(opt, null); return((ret == -1) ? false: (Object)(new Integer(ret))); case SocketOptions_Fields.SO_REUSEADDR: ret = SocketGetOption(opt, null); return(Convert.ToBoolean(ret != -1)); case SocketOptions_Fields.SO_BINDADDR: InetAddressContainer @in = new InetAddressContainer(); ret = SocketGetOption(opt, @in); return(@in.Addr); case SocketOptions_Fields.SO_SNDBUF: case SocketOptions_Fields.SO_RCVBUF: ret = SocketGetOption(opt, null); return(new Integer(ret)); case SocketOptions_Fields.IP_TOS: try { ret = SocketGetOption(opt, null); if (ret == -1) // ipv6 tos { return(TrafficClass); } else { return(ret); } } catch (SocketException) { // TODO - should make better effort to read TOS or TCLASS return(TrafficClass); // ipv6 tos } case SocketOptions_Fields.SO_KEEPALIVE: ret = SocketGetOption(opt, null); return(Convert.ToBoolean(ret != -1)); // should never get here default: return(null); } }