internal TcpClientTransportSink(String channelURI, TcpClientChannel channel)
        {
            String objectURI;

            _channel = channel;
            String simpleChannelUri = TcpChannelHelper.ParseURL(channelURI, out objectURI);

            ClientSocketCache = new SocketCache(new SocketHandlerFactory(this.CreateSocketHandler), _socketCachePolicy,
                                                _socketCacheTimeout);
            // extract machine name and port
            Uri uri = new Uri(simpleChannelUri);

            if (uri.IsDefaultPort)
            {
                // If there is no colon, then there is no port number.
                throw new RemotingException(
                          String.Format(
                              CultureInfo.CurrentCulture, CoreChannel.GetResourceString(
                                  "Remoting_Tcp_UrlMustHavePort"),
                              channelURI));
            }
            m_machineName = uri.Host;
            m_port        = uri.Port;

            _machineAndPort = m_machineName + ":" + m_port;
        } // TcpClientTransportSink
예제 #2
0
        internal TcpClientTransportSink(String channelURI)
        {
            String objectURI;
            String simpleChannelUri = TcpChannelHelper.ParseURL(channelURI, out objectURI);

            // extract machine name and port
            int start = simpleChannelUri.IndexOf("://");

            start += 3;
            int index = simpleChannelUri.IndexOf(':', start);

            if (index == -1)
            {
                // If there is no colon, then there is no port number.
                throw new RemotingException(
                          String.Format(
                              CoreChannel.GetResourceString(
                                  "Remoting_Tcp_UrlMustHavePort"),
                              channelURI));
            }

            m_machineName = simpleChannelUri.Substring(start, index - start);
            m_port        = Int32.Parse(simpleChannelUri.Substring(index + 1));

            _machineAndPort = m_machineName + ":" + m_port;
        } // TcpClientTransportSink
        internal TcpClientTransportSink(string channelURI, TcpClientChannel channel)
        {
            string str;

            this._socketCacheTimeout = TimeSpan.FromSeconds(10.0);
            this._spn        = string.Empty;
            this._retryCount = 1;
            this._tokenImpersonationLevel = TokenImpersonationLevel.Identification;
            this._protectionLevel         = ProtectionLevel.EncryptAndSign;
            this._channel = channel;
            string uriString = TcpChannelHelper.ParseURL(channelURI, out str);

            this.ClientSocketCache = new SocketCache(new SocketHandlerFactory(this.CreateSocketHandler), this._socketCachePolicy, this._socketCacheTimeout);
            Uri uri = new Uri(uriString);

            if (uri.IsDefaultPort)
            {
                throw new RemotingException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_UrlMustHavePort"), new object[] { channelURI }));
            }
            this.m_machineName   = uri.Host;
            this.m_port          = uri.Port;
            this._machineAndPort = this.m_machineName + ":" + this.m_port;
        }
        } // ChannelName

        // returns channelURI and places object uri into out parameter
        /// <include file='doc\CombinedTcpChannel.uex' path='docs/doc[@for="TcpChannel.Parse"]/*' />
        public String Parse(String url, out String objectURI)
        {
            return(TcpChannelHelper.ParseURL(url, out objectURI));
        } // Parse
예제 #5
0
        } // ReadContentLength

        protected void ReadToEndOfHeaders(BaseTransportHeaders headers)
        {
            bool   bError       = false;
            String statusPhrase = null;

            UInt16 headerType = ReadUInt16();

            while (headerType != TcpHeaders.EndOfHeaders)
            {
                if (headerType == TcpHeaders.Custom)
                {
                    String headerName  = ReadCountedString();
                    String headerValue = ReadCountedString();

                    headers[headerName] = headerValue;
                }
                else
                if (headerType == TcpHeaders.RequestUri)
                {
                    ReadAndVerifyHeaderFormat("RequestUri", TcpHeaderFormat.CountedString);

                    // read uri (and make sure that no channel specific data is present)
                    String uri = ReadCountedString();

                    String channelURI;
                    String objectURI;
                    channelURI = TcpChannelHelper.ParseURL(uri, out objectURI);
                    if (channelURI == null)
                    {
                        objectURI = uri;
                    }

                    headers.RequestUri = objectURI;
                }
                else
                if (headerType == TcpHeaders.StatusCode)
                {
                    ReadAndVerifyHeaderFormat("StatusCode", TcpHeaderFormat.UInt16);

                    UInt16 statusCode = ReadUInt16();
                    // We'll throw an exception here if there was an error. If an error
                    //   occurs above the transport level, the status code will still be
                    //   success here.
                    if (statusCode != TcpStatusCode.Success)
                    {
                        bError = true;
                    }
                }
                else
                if (headerType == TcpHeaders.StatusPhrase)
                {
                    ReadAndVerifyHeaderFormat("StatusPhrase", TcpHeaderFormat.CountedString);

                    statusPhrase = ReadCountedString();
                }
                else
                if (headerType == TcpHeaders.ContentType)
                {
                    ReadAndVerifyHeaderFormat("Content-Type", TcpHeaderFormat.CountedString);

                    String contentType = ReadCountedString();
                    headers.ContentType = contentType;
                }
                else
                {
                    // unknown header: Read header format and ignore rest of data
                    byte headerFormat = (byte)ReadByte();

                    switch (headerFormat)
                    {
                    case TcpHeaderFormat.Void: break;

                    case TcpHeaderFormat.CountedString: ReadCountedString(); break;

                    case TcpHeaderFormat.Byte: ReadByte(); break;

                    case TcpHeaderFormat.UInt16: ReadUInt16(); break;

                    case TcpHeaderFormat.Int32: ReadInt32(); break;

                    default:
                    {
                        // unknown format
                        throw new RemotingException(
                                  String.Format(
                                      CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_UnknownHeaderType"),
                                      headerType, headerFormat));
                    }
                    } // switch (format)
                }

                // read next header token
                headerType = ReadUInt16();
            } // loop until end of headers

            // if an error occurred, throw an exception
            if (bError)
            {
                if (statusPhrase == null)
                {
                    statusPhrase = "";
                }

                throw new RemotingException(
                          String.Format(
                              CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_GenericServerError"),
                              statusPhrase));
            }
        } // ReadToEndOfHeaders
 public string Parse(string url, out string objectURI)
 {
     return(TcpChannelHelper.ParseURL(url, out objectURI));
 }
예제 #7
0
        protected void ReadToEndOfHeaders(BaseTransportHeaders headers)
        {
            bool   flag = false;
            string str  = null;

            for (ushort i = base.ReadUInt16(); i != 0; i = base.ReadUInt16())
            {
                switch (i)
                {
                case 1:
                {
                    string str2 = this.ReadCountedString();
                    string str3 = this.ReadCountedString();
                    headers[str2] = str3;
                    break;
                }

                case 4:
                {
                    string str6;
                    this.ReadAndVerifyHeaderFormat("RequestUri", 1);
                    string url = this.ReadCountedString();
                    if (TcpChannelHelper.ParseURL(url, out str6) == null)
                    {
                        str6 = url;
                    }
                    headers.RequestUri = str6;
                    break;
                }

                case 2:
                    this.ReadAndVerifyHeaderFormat("StatusCode", 3);
                    if (base.ReadUInt16() != 0)
                    {
                        flag = true;
                    }
                    break;

                case 3:
                    this.ReadAndVerifyHeaderFormat("StatusPhrase", 1);
                    str = this.ReadCountedString();
                    break;

                case 6:
                {
                    this.ReadAndVerifyHeaderFormat("Content-Type", 1);
                    string str7 = this.ReadCountedString();
                    headers.ContentType = str7;
                    break;
                }

                default:
                {
                    byte num3 = (byte)base.ReadByte();
                    switch (num3)
                    {
                    case 1:
                    {
                        this.ReadCountedString();
                        continue;
                    }

                    case 2:
                    {
                        base.ReadByte();
                        continue;
                    }

                    case 3:
                    {
                        base.ReadUInt16();
                        continue;
                    }

                    case 4:
                    {
                        base.ReadInt32();
                        continue;
                    }
                    }
                    throw new RemotingException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_UnknownHeaderType"), new object[] { i, num3 }));
                }
                }
            }
            if (flag)
            {
                if (str == null)
                {
                    str = "";
                }
                throw new RemotingException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_GenericServerError"), new object[] { str }));
            }
        }