Example #1
0
        public void HandleWrite(IOStream stream)
        {
            SocketStream sstream = (SocketStream)stream;

            while (bytes.Count > 0)
            {
                int len = -1;
                try {
                    len = sstream.socket.Send(bytes);
                } catch (SocketException se) {
                    if (se.SocketErrorCode == SocketError.WouldBlock || se.SocketErrorCode == SocketError.TryAgain)
                    {
                        return;
                    }
                    sstream.Close();
                } catch (Exception e) {
                    sstream.Close();
                } finally {
                    if (len != -1)
                    {
                        int num_segments = bytes.Count;
                        IOStream.AdjustSegments(len, bytes);
                        segments_written = num_segments - bytes.Count;
                    }
                }
            }

            FireCallbacks();
            IsComplete = (bytes.Count == 0);
        }
Example #2
0
        public void HandleWrite(IOStream stream)
        {
            SocketStream sstream = (SocketStream)stream;

            while (this.buffers.Count > 0)
            {
                int            len = -1;
                int            error;
                ByteBufferS [] bs = CreateBufferSArray();
                len = sstream.Send(bs, bs.Length, out error);

                if (len < 0 && error == 0)
                {
                    return;
                }

                if (len != -1)
                {
                    int num_segments = buffers.Count;
                    IOStream.AdjustSegments(len, buffers);
                    segments_written = num_segments - buffers.Count;
                }
            }

            FireCallbacks();
            IsComplete = (buffers.Count == 0);
        }