public TcpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; char[] separators = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(separators); int i = 0; while(i < arr.Length) { if(arr[i].Length == 0) { i++; continue; } string option = arr[i++]; if(option.Length != 2 || option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `tcp " + str + "'"; throw e; } string argument = null; if(i < arr.Length && arr[i].Length > 0 && arr[i][0] != '-') { argument = arr[i++]; if(argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } switch(option[1]) { case 'h': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `tcp " + str + "'"; throw e; } _host = argument; break; } case 'p': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `tcp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } if(_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `tcp " + str + "'"; throw e; } break; } case 't': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -t option in endpoint `tcp " + str + "'"; throw e; } try { _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } break; } case 'z': { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `tcp " + str + "'"; throw e; } _compress = true; break; } default: { parseOption(option, argument, "tcp", str); break; } } } if(_host == null) { _host = _instance.defaultsAndOverrides().defaultHost; } else if(_host.Equals("*")) { if(oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `tcp " + str + "'"); } } if(_host == null) { _host = ""; } calcHashValue(); }
public TcpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; char[] separators = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(separators); int i = 0; while (i < arr.Length) { if (arr[i].Length == 0) { i++; continue; } string option = arr[i++]; if (option.Length != 2 || option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `tcp " + str + "'"; throw e; } string argument = null; if (i < arr.Length && arr[i].Length > 0 && arr[i][0] != '-') { argument = arr[i++]; if (argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } switch (option[1]) { case 'h': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `tcp " + str + "'"; throw e; } _host = argument; break; } case 'p': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `tcp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } if (_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `tcp " + str + "'"; throw e; } break; } case 't': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -t option in endpoint `tcp " + str + "'"; throw e; } try { _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } break; } case 'z': { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `tcp " + str + "'"; throw e; } _compress = true; break; } default: { parseOption(option, argument, "tcp", str); break; } } } if (_host == null) { _host = _instance.defaultsAndOverrides().defaultHost; } else if (_host.Equals("*")) { if (oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `tcp " + str + "'"); } } if (_host == null) { _host = ""; } calcHashValue(); }
public UdpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { instance_ = instance; _host = null; _port = 0; _connect = false; _compress = false; string delim = " \t\n\r"; int beg; int end = 0; while(true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(beg == -1) { break; } end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } string option = str.Substring(beg, end - beg); if(option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw e; } string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(argumentBeg != -1 && str[argumentBeg] != '-') { beg = argumentBeg; if(str[beg] == '\"') { end = IceUtilInternal.StringUtil.findFirstOf(str, "\"", beg + 1); if(end == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw e; } else { ++end; } } else { end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } } argument = str.Substring(beg, end - beg); if(argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } if(option.Equals("-h")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw e; } _host = argument; } else if(option.Equals("-p")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `udp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else if(option.Equals("-c")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw e; } _connect = true; } else if(option.Equals("-z")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw e; } _compress = true; } else if(option.Equals("-v") || option.Equals("-e")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for " + option + " option in endpoint " + "`udp " + str + "'"; throw e; } try { Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); if(v.major != 1 || v.minor != 0) { instance_.initializationData().logger.warning("deprecated udp endpoint option: " + option); } } catch(Ice.VersionParseException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid version `" + argument + "' in endpoint `udp " + str + "':\n" + ex.str; throw e; } } else if(option.Equals("--interface")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw e; } _mcastInterface = argument; } else if(option.Equals("--ttl")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else { parseOption(option, argument, "udp", str); } } if(_host == null) { _host = instance_.defaultsAndOverrides().defaultHost; } else if(_host.Equals("*")) { if(oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'"); } } if(_host == null) { _host = ""; } calcHashValue(); }
public UdpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { instance_ = instance; _host = null; _port = 0; _connect = false; _compress = false; string delim = " \t\n\r"; int beg; int end = 0; while (true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if (beg == -1) { break; } end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if (end == -1) { end = str.Length; } string option = str.Substring(beg, end - beg); if (option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw e; } string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if (argumentBeg != -1 && str[argumentBeg] != '-') { beg = argumentBeg; if (str[beg] == '\"') { end = IceUtilInternal.StringUtil.findFirstOf(str, "\"", beg + 1); if (end == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw e; } else { ++end; } } else { end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if (end == -1) { end = str.Length; } } argument = str.Substring(beg, end - beg); if (argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } if (option.Equals("-h")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw e; } _host = argument; } else if (option.Equals("-p")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `udp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if (_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else if (option.Equals("-c")) { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw e; } _connect = true; } else if (option.Equals("-z")) { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw e; } _compress = true; } else if (option.Equals("-v") || option.Equals("-e")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for " + option + " option in endpoint " + "`udp " + str + "'"; throw e; } try { Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); if (v.major != 1 || v.minor != 0) { instance_.initializationData().logger.warning("deprecated udp endpoint option: " + option); } } catch (Ice.VersionParseException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid version `" + argument + "' in endpoint `udp " + str + "':\n" + ex.str; throw e; } } else if (option.Equals("--interface")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw e; } _mcastInterface = argument; } else if (option.Equals("--ttl")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if (_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else { parseOption(option, argument, "udp", str); } } if (_host == null) { _host = instance_.defaultsAndOverrides().defaultHost; } else if (_host.Equals("*")) { if (oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'"); } } if (_host == null) { _host = ""; } calcHashValue(); }
public UdpEndpointI(Instance instance, string str, bool oaEndpoint) { instance_ = instance; _host = null; _port = 0; _protocolMajor = Protocol.protocolMajor; _protocolMinor = Protocol.protocolMinor; _encodingMajor = Protocol.encodingMajor; _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = false; string delim = " \t\n\r"; int beg; int end = 0; while(true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(beg == -1) { break; } end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } string option = str.Substring(beg, end - beg); if(option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw e; } string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(argumentBeg != -1 && str[argumentBeg] != '-') { beg = argumentBeg; if(str[beg] == '\"') { end = IceUtilInternal.StringUtil.findFirstOf(str, "\"", beg + 1); if(end == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw e; } else { ++end; } } else { end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } } argument = str.Substring(beg, end - beg); if(argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } if(option.Equals("-v")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -v option in endpoint `udp " + str + "'"; throw e; } int pos = argument.IndexOf((System.Char) '.'); if(pos == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "malformed protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } string majStr = argument.Substring(0, (pos) - (0)); string minStr = argument.Substring(pos + 1, (argument.Length) - (pos + 1)); int majVersion; int minVersion; try { majVersion = System.Int32.Parse(majStr, CultureInfo.InvariantCulture); minVersion = System.Int32.Parse(minStr, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "range error in protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion != Protocol.protocolMajor) { Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); e.badMajor = majVersion < 0?majVersion + 255:majVersion; e.badMinor = minVersion < 0?minVersion + 255:minVersion; e.major = Protocol.protocolMajor; e.minor = Protocol.protocolMinor; throw e; } _protocolMajor = (byte)majVersion; _protocolMinor = (byte)minVersion; } else if(option.Equals("-e")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -e option in endpoint `udp " + str + "'"; throw e; } int pos = argument.IndexOf((System.Char) '.'); if(pos == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "malformed encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } string majStr = argument.Substring(0, (pos) - (0)); string minStr = argument.Substring(pos + 1, (argument.Length) - (pos + 1)); int majVersion; int minVersion; try { majVersion = System.Int32.Parse(majStr, CultureInfo.InvariantCulture); minVersion = System.Int32.Parse(minStr, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "range error in encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion != Protocol.encodingMajor) { Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); e.badMajor = majVersion < 0?majVersion + 255:majVersion; e.badMinor = minVersion < 0?minVersion + 255:minVersion; e.major = Protocol.encodingMajor; e.minor = Protocol.encodingMinor; throw e; } _encodingMajor = (byte)majVersion; _encodingMinor = (byte)minVersion; } else if(option.Equals("-h")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw e; } _host = argument; } else if(option.Equals("-p")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `udp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else if(option.Equals("-c")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw e; } _connect = true; } else if(option.Equals("-z")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw e; } _compress = true; } else if(option.Equals("--interface")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw e; } _mcastInterface = argument; } else if(option.Equals("--ttl")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unknown option `" + option + "' in `udp " + str + "'"; throw e; } } if(_host == null) { _host = instance_.defaultsAndOverrides().defaultHost; } else if(_host.Equals("*")) { if(oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'"); } } if(_host == null) { _host = ""; } calcHashValue(); }