[ace-users] [Fwd: Unable to run simple ACE programs in cygwin]

Adam Mitz mitza at ociweb.com
Thu Jun 28 13:07:41 CDT 2007


Hi Ananth,

I'll first echo Johnny's statements about "official" support for Cygwin. 
  Patches from users are always apprciated, or you could fund your 
choice of commercial support company 
(http://www.cs.wustl.edu/~schmidt/commercial-support.html) to do this work.

That being said, I've seen error 128 on Windows when it can't find the 
DLL to load when the process starts.  You may want to check your PATH 
settings.

Thanks,
Adam Mitz
Software Engineer
Object Computing, Inc.



-------- Original Message --------
Subject: Unable to run simple ACE programs in cygwin
Date: Thu, 28 Jun 2007 01:50:03 -0700
From: ananth <ananthbv at gmail.com>
Organization: http://groups.google.com
Newsgroups: comp.soft-sys.ace

Hi,

I am running a simple client and server ACE programs on cygwin.
Compilation does not give any error. No error is shown at runtime
also, but it does not seem to run either. When I run the server, it
exits immediately. it does not block on 'accept' . 'echo $?' on the
shell shows return code as 128. Here are the things I tried:

1. 'ps -ef | grep <server / client>' does not show anything.
2. I ran make on the 'inserver' and 'inclient' programs in the
'examples' directory, ran the server and client, that also did not
give any result (and 'ps -ef' did not show any result here too).
3. I put in a couple of 'printf' at the beginning of 'main', this too
did not get printed at run-time. But commenting out all code except
the 'printf' worked.

Can someone please help?

I am compiling the code using this command:
g++ <server / client program name> -I/cygdrive/c/cygwin/ACE_wrappers/ /
cygdrive/c/cygwin/ACE_wrappers/ace/libACE.dll.a

Other details:

ACE version is 5.5.9.

$ g++ --version
g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$
$ uname -a
CYGWIN_NT-5.0 cpv2000 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin


Here are the programs:

// Server
#include "ace/INET_Addr.h"
#include "ace/SOCK_Stream.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/Log_Msg.h"
int main (int, char * argv [])
{
         ACE_INET_Addr port_to_listen ("HAStatus");
         ACE_SOCK_Acceptor acceptor;

         if (acceptor.open (port_to_listen, 1) == -1)
         {
                 ACE_ERROR ((LM_ERROR, "%p\n", "acceptor.open"));
                 return( 100 );
         }

         while (1)
         {
                 ACE_SOCK_Stream peer;
                 ACE_INET_Addr peer_address;
                 ACE_Time_Value timeout (10, 0);

                 if (acceptor.accept (peer, &peer_address, &timeout, 0)
== -1)
                 {
                         if (ACE_OS::last_error() == EINTR)
                                 ACE_DEBUG ((LM_DEBUG, "(%P|%t)
Interrupted while " "waiting for client connection\n"));
                         else if (ACE_OS::last_error() == ETIMEDOUT)
                                 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Timeout
while " "waiting for client connection\n"));
                 }
                 else if (peer_address.get_port_number() == 0)
                 {
                         ACE_DEBUG ((LM_DEBUG, "(%P|%t) Invalid address
for client\n"));
                 }
                 else if (peer.get_handle () == ACE_INVALID_HANDLE)
                 {
                         ACE_ERROR ((LM_ERROR, "%p\n", "accept"));
                 }
                 else
                 {
                         char buffer[4096];
                         ssize_t bytes_received;
                         while ((bytes_received = peer.recv (buffer,
sizeof(buffer)-1)) != -1)
                         {
                                 buffer[bytes_received] = 0;
                                 peer.send_n (buffer, bytes_received
+1);
                         }
                         peer.close ();
                 }
         }
         return (0);
}



// Client
#include "ace/INET_Addr.h"
#include "ace/SOCK_Stream.h"
#include "ace/SOCK_Connector.h"
#include "ace/Log_Msg.h"

int main (int argc, char *argv[])
{
         ACE_INET_Addr srvr (50000, ACE_LOCALHOST);
         ACE_SOCK_Connector connector;
         ACE_SOCK_Stream peer;

         if (-1 == connector.connect (peer, srvr))
                 ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), 1);

         int bc;
         char buf[64];

         peer.send_n ("uptime\n", 7);
         bc = peer.recv (buf, sizeof(buf));
         write (1, buf, bc);
         peer.close ();
         return (0);
}



More information about the Ace-users mailing list