Loading ...
Sorry, an error occurred while loading the content.

RE: [eiffel_software] Binary data transfer

Expand Messages
  • Robert Jurjevic
    Hello Manu, ... I am talking about server knowing client being disconnected, but also do not see why client knowing server being disconnected would not be
    Message 1 of 6 , Nov 1, 2004
    • 0 Attachment
      Hello Manu,

      > There is no notification mechanism for a client
      > to know that the connection has
      > been closed.

      I am talking about server knowing client being disconnected, but also do not see why client knowing server being disconnected would not be possible. It is a usual practice that server stops serving a client which has been closed connection and that client wishes to know if the server has gone. The connection closure is detected on an attempt to read or write from or on the socket.

      I have fixed the bug in SOCKET in order for server reading from the socket using SOCKET `read' detects the disconnected client. But, the fixes should be done to all other relevant features in SOCKET class.

      My example is working fine and my server can detect the client connection closure when reading from the socket (using SOCKET `read'). I have not implemented the fix in SOCKET `write', etc., but that should be possible, covering all possible combinations of peer disconnection detection (client or server while reading or writing).

      Also, I have fixed the bug in SOCKET's `connect' which would report successful connection to the non-running server. My connect `my_connect' is waiting until the server is started (or I guess it would timeout if server is not available for a longer period of time).

      My version of `read', `my_read', is also more efficient (or should I say acceptably efficient in contrast to original `read' which is unacceptably inefficient) as it does not do unnecessary object and memory creation and copying. Any check of `my_read' would be appreciated.

      My fixes, as an example, are given in the P.S. of this message.

      In spite of these few bugs in SOCKET EiffelNet has helped me to writhe the desired test application much faster that say in C++, or some other OO language not having base class libraries. It is fortunate that one has access to class sources and can do fixes if necessary.

      Yours sincerely,

      Robert Jurjevic

      P.S.

      my_connect is
      -- Connect socket to peer address.
      require
      socket_exists: exists;
      valid_peer_address: peer_address /= Void
      local
      ext: ANY
      retried: BOOLEAN
      do
      if not retried then
      ext := peer_address.socket_address;
      c_connect (descriptor, $ext, peer_address.count);
      is_open_write := True;
      is_open_read := True
      end
      rescue
      if not assertion_violation then
      is_open_read := False
      is_open_write := False
      --retried := True -- rj
      retry
      end
      end;


      --read (size: INTEGER): PACKET is
      my_read (a_packet: PACKET): BOOLEAN is
      -- Read packet `a_packet' from socket. Reruns True if connection
      -- was closed by the peer.
      require
      socket_exists: exists;
      opened_for_read: is_open_read
      local
      --l_data, recv_packet: MEMORY_STREAM;
      amount_read: INTEGER;
      return_val: INTEGER;
      ext_data: POINTER;
      closed: BOOLEAN -- rj
      size: INTEGER -- rj
      do
      size := a_packet.count -- rj
      --ext_data := ext_data.memory_alloc (size)
      ext_data := a_packet.data.area -- rj
      from
      amount_read := 0
      until
      --amount_read = size
      amount_read = size or closed -- rj
      loop
      return_val := c_read_stream (descriptor, size - amount_read, ext_data);
      if return_val > 0 then
      --create recv_packet.make_from_pointer (ext_data, return_val) -- rj
      --if l_data = Void then
      -- l_data := clone (recv_packet)
      --else
      -- l_data.append (recv_packet)
      --end
      ext_data := ext_data + return_val -- rj
      amount_read := amount_read + return_val
      else
      --if amount_read = 0 then
      -- l_data := Void
      --end
      if return_val = 0 then -- rj
      closed := True
      end
      end
      end
      --if l_data /= Void then
      -- create Result.make_from_memory_stream (l_data)
      --end
      Result := closed -- rj
      end


      -----Original Message-----
      From: Emmanuel Stapf [ES] [mailto:manus@...]
      Sent: 29 October 2004 17:13
      To: eiffel_software@yahoogroups.com
      Subject: RE: [eiffel_software] Binary data transfer



      > In EiffelNet, how do you determine if a remote client has
      > closed his connection? Also, how do you determine the number
      > of bytes available in the input buffer, usually a call to
      > ioctl -> FIONREAD.

      There is no notification mechanism for a client to know that the connection has
      been closed. One has to protect his code using `rescue' clauses to ensure a proper
      behavior.

      There is no feature to let you know how much data needs to be read.

      Regards,
      Manu





      Yahoo! Groups Links








      _____________________________________________________________________
      This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com

      _____________________________________________________________________
      This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com
    Your message has been successfully submitted and would be delivered to recipients shortly.