[Ace-users] Re: Reading from standard input inside of a Connector

djh danjhiggi at gmail.com
Mon Jul 23 12:26:08 CDT 2007


This was my first posting to this group. Below I am restating my issue
using the format recommended by Dr. Schmidt.
-thank you for your response

Subject: [area]: Reading from Standard Input from a Connector

    ACE VERSION: 5.5

    HOST MACHINE and OPERATING SYSTEM:
			x86_64 GNU/Linux Fedora core 6

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST: same
    COMPILER NAME AND VERSION (AND PATCHLEVEL): gcc version 4.1.1
20070105 (Red Hat 4.1.1-51)

    THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform-
    specific file, simply state which one]: "ace/config-linux.h"

    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE:
			$(ACE_ROOT)/include/makeinclude/platform_linux.GNU

    CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/
default.features
    (used by MPC when you generate your own makefiles): ??

    AREA/CLASS/EXAMPLE AFFECTED:
			Connector Framework as defined in the ACE Programmer's Guide
Section "7.6.3: Using ACE_Connector, and Other Features"

    DOES THE PROBLEM AFFECT:
      EXECUTION

    SYNOPSIS:
			Reading from Standard input breaks my Connector Client.

    DESCRIPTION:

I built the single-threaded event-handling server that listens on a
socket as defined in The ACE Programmer's Guide section "7.6.1 Using
ACE_Acceptor and ACE_Svc_handler". I then built a Client using the
Connector Framework as defined in the ACE Programmer's Guide Section
"7.6.3: Using ACE_Connector, and Other Features".

Initially, my connector client took locally-defined const static
strings and sent them to the server (via a socket
connection). Everything worked great: the Acceptor received the
message, formulated a response, sent it back, and the client read it
correctly.

Then in order to make the test code more useful I had the Connector's
method responsible for gathering input data, handle_timeout(), read
strings from the input stream "cin" rather than use the statically
defined
strings.  The client was able to put the data on the socket but the
server wasn't able to read data off of the socket. It said that
the amount of bytes read was zero.

After troubleshooting for a while, I reverted the code back to using
the statically defined strings and got it working again.

Then I simply added the following two lines.


 string test.
 cin >> test;


Even though I don't do anything with the "test" string (ie. send it on
the socket), it still messes up the listening server (Acceptor).

If I comment out the 2nd line above, it works. If I uncomment, it
breaks.

I'm trying to figure out if/why the C++'s input stream doesn't work
from inside a Connector's event handling callback routines.

If someone tells me that it should work then this is useful
information
and I'll continue to push ahead. Meanwhile, I'll try reading from a
file stream and see if that works.


    REPEAT BY:

    SAMPLE FIX/WORKAROUND:



More information about the Ace-users mailing list