finally { try { if (socket != null && !socket.isClosed()) { socket.setSoTimeout(Functional_ORB.TANDEM_REQUESTS); SocketRepository.put_socket(key, socket ); } } catch (IOException scx) { InternalError ierr = new InternalError(); ierr.initCause(scx); throw ierr; } }
  public synchronized binaryReply submit()  {    gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader();    // The byte order will be Big Endian by default.    header.message_type = gnu.CORBA.GIOP.MessageHeader.REQUEST;    header.version = useVersion(ior.Internet.version);    RequestHeader rh = header.create_request_header();    rh.object_key = ior.key;    rh.operation = m_operation;    // Prepare the submission.    cdrBufOutput request_part = new cdrBufOutput();    request_part.setOffset(header.getHeaderSize());    request_part.setVersion(header.version);    request_part.setCodeSet(cxCodeSet.negotiate(ior.CodeSets));    request_part.setOrb(orb);    // This also sets the stream encoding to the encoding, specified    // in the header.    rh.write(request_part);    if (m_args != null && m_args.count() > 0)      {        write_parameters(header, request_part);        if (m_parameter_buffer != null)          throw new BAD_INV_ORDER("Please either add parameters or " +                                  "write them into stream, but not both " +                                  "at once."                                 );      }    if (m_parameter_buffer != null)      {        write_parameter_buffer(header, request_part);      }    // Now the message size is available.    header.message_size = request_part.buffer.size();    try      {        Socket socket = new Socket(ior.Internet.host, ior.Internet.port);        OutputStream socketOutput = socket.getOutputStream();        // Write the message header.        header.write(socketOutput);        // Write the request header and parameters (if present).        request_part.buffer.writeTo(socketOutput);        socketOutput.flush();        if (!socket.isClosed())          {            MessageHeader response_header = new MessageHeader();            InputStream socketInput = socket.getInputStream();            response_header.read(socketInput);            byte[] r = new byte[ response_header.message_size ];            int n = 0;            reading:            while (n < r.length)              {                n = socketInput.read(r, n, r.length - n);              }            socketInput.close();            return new binaryReply(orb, response_header, r);          }        else          return EMPTY;      }    catch (IOException ex1)      {        ex1.printStackTrace();        return null;      }  }