コード例 #1
0
ファイル: TransceiverI.cs プロジェクト: stick/zeroc-ice
 public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax)
 {
     if (buf.size() > messageSizeMax)
     {
         IceInternal.Ex.throwMemoryLimitException(buf.size(), messageSizeMax);
     }
 }
コード例 #2
0
ファイル: TransceiverI.cs プロジェクト: stick/zeroc-ice
        public void finishWrite(IceInternal.Buffer buf)
        {
            if (_fd == null) // Transceiver was closed
            {
                if (buf.size() - buf.b.position() < _maxSendPacketSize)
                {
                    buf.b.position(buf.size()); // Assume all the data was sent for at-most-once semantics.
                }
                _writeResult = null;
                return;
            }

            if (_state < StateConnected && _state != StateProxyConnectRequest)
            {
                return;
            }

            Debug.Assert(_fd != null && _writeResult != null);

            try
            {
                if (_stream != null)
                {
                    _stream.EndWrite(_writeResult);
                }
                else
                {
                    _fd.EndSend(_writeResult);
                }
                _writeResult = null;

                int packetSize = buf.b.remaining();
                if (_maxSendPacketSize > 0 && packetSize > _maxSendPacketSize)
                {
                    packetSize = _maxSendPacketSize;
                }

                if (_instance.networkTraceLevel() >= 3)
                {
                    string s = "sent " + packetSize + " of " + packetSize + " bytes via ssl\n" + ToString();
                    _logger.trace(_instance.networkTraceCategory(), s);
                }

                if (_stats != null)
                {
#pragma warning disable 618
                    _stats.bytesSent(type(), packetSize);
#pragma warning restore 618
                }

                buf.b.position(buf.b.position() + packetSize);

                if (_state == StateProxyConnectRequest)
                {
                    _proxy.endWriteConnectRequest(buf);
                }
            }
            catch (IOException ex)
            {
                if (IceInternal.Network.connectionLost(ex))
                {
                    throw new Ice.ConnectionLostException(ex);
                }
                if (IceInternal.Network.timeout(ex))
                {
                    throw new Ice.TimeoutException();
                }
                throw new Ice.SocketException(ex);
            }
            catch (Ice.LocalException)
            {
                throw;
            }
            catch (ObjectDisposedException ex)
            {
                throw new Ice.ConnectionLostException(ex);
            }
            catch (Exception ex)
            {
                throw new Ice.SyscallException(ex);
            }
        }