AIX 3.2 vs AIX 4.1 Implementation of Berkeley sockets

AIX 3.2 vs AIX 4.1 Implementation of Berkeley sockets

Post by R. Michael Gillmor » Sat, 19 Oct 1996 04:00:00



Hello all ...

I have recently upgraded my RS/6000 from AIX 3.2 to AIX 4.1.  The
installation was relatively painless considering the hardware upgrade
that we rolled in at the same time.  We now have a bigger problem,
though.  We have written code that communicates to a Tandem machine,
and to a SunOS machine using Berkeley sockets.  If we run the code
which was compiled and linked on the 3.2 machine (we kept one around
just in case), it runs just fine.  This same code also runs on the
SunOS side of the connection.  Communications are flawless.

The problem comes when we try to run the code which was compiled on
the 4.1 AIX machine.  We either get ECONNREFUSED or EACCESS errors
on the communications ports.

I posted a couple of times before with no response.  Can someone help.
Maybe even a note to indicate that you have read this would at least
give me a good feeling that it really got beyond the firewall.

Thanks,

R. Michael "Okie" Gillmore
Highway Transportation Electronics
OBC Office Software
Internet -- rmgil...@cca.rockwell.com

typedef enum
{
        UNDEFINED = -1,
        INCOMING,
        OUTGOING

} direction_t;

typedef char *          IP_Address_t;
typedef void *          socket_t;

typedef struct
{
        IP_Address_t    d_IP_Address;
        int                             d_socketID;
        int                             d_portNumber;
        direction_t             d_whichDirection;
        boolean_t               d_isConnected;

} realSocket_t;

int
establishConnection( socket_t definedSocket )
{
        /*
         *      This function establishes a TCP/IP connection with depending upon
the
         *      direction.  If it is incoming, we wait for the connection.  If it is
         *      outgoing, we request a connection from the other end
         */

        realSocket_t *                          socketPtr = ( realSocket_t * )definedSocket;
        static struct sockaddr_in       serverAddress;
        static struct sockaddr          remoteAddress;
        int                                                     err_ret;
        static int                                      remoteLength;

        /*
         *      Initialize the server address structure.
         */

        memset( &serverAddress, 0, sizeof( serverAddress ) );

        /*
         *      Open a socket.  This call is to the OS library
         */

        socketPtr->d_socketID = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
        if ( socketPtr->d_socketID < 0 )
        {
                /*
                 *      This is an error condition.  We need to determine
                 *      what we should do here
                 */

                l2k_log( 9, "error from socket(), error code == '%d'", errno );
                disconnect( definedSocket );
        }
        else
        {
                if ( socketPtr->d_whichDirection == INCOMING )
                {
                        /*
                         *      Since we are incoming, we want to accept any connection on the
                         *      designated port
                         */

                        serverAddress.sin_family = AF_INET;
                        serverAddress.sin_addr.s_addr = htonl( INADDR_ANY );
                        serverAddress.sin_port = htons( socketPtr->d_portNumber );

                        /*
                         *      Associate our port number and IP address
                         */

                        err_ret = bind( socketPtr->d_socketID,
                                ( struct sockaddr * )&serverAddress, sizeof( serverAddress ) );
                        if ( err_ret < 0 )
                        {
                                /*
                                 *      We can't even associate our port number and address.
                                 *      There are some serious problems here!  Disconnect
                                 *      and we have done all that can be done
                                 */

                                l2k_log( 0, "Unable to bind to address, error reported is %d",
                                        errno );
                                disconnect( definedSocket );
                        }
                        else
                        {
                                /*
                                 *      We will wait forever for a connection.  Incoming sockets
                                 *      simply means that we are waiting for the phone to ring
                                 */

                                err_ret = listen( socketPtr->d_socketID, NUMBER_CONNECTIONS );
                                if ( err_ret < 0 )
                                {
                                        /*
                                         *      There was some sort of error ... Close the socket
                                         */

                                        disconnect( definedSocket );
                                        l2k_log( 0, "listen returned an error of %d", errno );
                                }
                                else
                                {
                                        /*
                                         *      The phone has rung, and it is a "collect call".  We
                                         *      need to see who is calling
                                         */

                                        err_ret = accept( socketPtr->d_socketID,
                                                &remoteAddress, &remoteLength );
                                        if ( err_ret < 0 )
                                        {
                                                /*
                                                 *      The calling party did not identify himself, so
                                                 *      an error was reported.  Close the socket
                                                 */

                                                disconnect( definedSocket );
                                                l2k_log( 0, "accept returned an error of %d", errno );
                                        }
                                        else
                                        {
                                                /*
                                                 *      Everything was OK!  Indicate that the connection
                                                 *      has been established
                                                 */

                                                socketPtr->d_socketID = err_ret;
                                                socketPtr->d_isConnected = TRUE;
                                        }
                                }       /*      listen was successful */
                        }       /*      bind successful */
                }       /*      INCOMING socket */
                else
                {
                        /*
                         *      To prevent us from waiting forever while attempting to establish
                         *      a connection with a remote server, we will set an alarm.
                         */

                        setupAlarm();

                        /*
                         *      Indicate with which server we are to communicate, and
                         *      on which port
                         */

                        serverAddress.sin_family = AF_INET;
                        serverAddress.sin_addr.s_addr = inet_addr( socketPtr->d_IP_Address );        
                        serverAddress.sin_port = htons( socketPtr->d_portNumber );

                        /*
                         *      Connect the socket to the server.
                         */

                        err_ret = connect( socketPtr->d_socketID,
                                ( struct sockaddr * )&serverAddress, sizeof( serverAddress ) );
                        if ( err_ret < 0 )
                        {
                                l2k_log( 0, "Connection attempt failed (%d, %d)", err_ret, errno );
                                alarm( 0 );

                                /*
                                 *      We could not establish a connection with the
                                 *      remote system.  There is a problem, so close the
                                 *      socket, and return to the caller with a socketID
                                 *      which is not valid
                                 */

                                disconnect( definedSocket );
                        }       /*      Socket connection failed */
                }       /*      OUTGOING socket */
        }       /*      socket ID received */

        return ( socketPtr->d_socketID );

}       /*      establishConnection() */

 
 
 

AIX 3.2 vs AIX 4.1 Implementation of Berkeley sockets

Post by Dave Plon » Thu, 24 Oct 1996 04:00:00



Quote:> Hello all ...

[I've restricted this follow-up to comp.unix.programmer...]

Quote:> I have recently upgraded my RS/6000 from AIX 3.2 to AIX 4.1.  The
> installation was relatively painless considering the hardware upgrade
> that we rolled in at the same time.  We now have a bigger problem,
> though.  We have written code that communicates to a Tandem machine,
> and to a SunOS machine using Berkeley sockets.  If we run the code
> which was compiled and linked on the 3.2 machine (we kept one around
> just in case), it runs just fine.  This same code also runs on the
> SunOS side of the connection.  Communications are flawless.
> The problem comes when we try to run the code which was compiled on
> the 4.1 AIX machine.  We either get ECONNREFUSED or EACCESS errors
> on the communications ports.

You get ECONNREFUSED or EACCESS from *which* system call(s)?
connect(2) and bind(2) respecively?  From the AIX 4.1.4 connect(2) and
bind(2) man pages, these errors mean this:

ECONNREFUSED    The attempt to connect was rejected.

EACCES  The requested address is protected, and the current user does
not have permission to access it.

What port are you trying to bind(2) or connect(2)?  Since you didn't
show us your /etc/services file entries or how in the heck the
d_portNumber member of your struct realSocket_t was initialized, there's
not much here to go on.  If I had to guess I'd say you forgot to
define the appropriate host and or services entries for this application
in /etc/services or to set up NIS if your using it.  Compare your services
files on your 3.2 machine vs. your 4.1 machine.  If that's the case, the
code should have complained that getservbyname(3) failed, if it's using that.

A good test, once you know your service name is to see if you can use
telnet as a generic TCP client and get a connection. eg.:

$ telnet otherhost servicename

Hope this helps,
Dave

--


 
 
 

AIX 3.2 vs AIX 4.1 Implementation of Berkeley sockets

Post by R. Michael Gillmor » Fri, 25 Oct 1996 04:00:00




> > Hello all ...

> [I've restricted this follow-up to comp.unix.programmer...]

> > I have recently upgraded my RS/6000 from AIX 3.2 to AIX 4.1.  The
> > installation was relatively painless considering the hardware upgrade
> > that we rolled in at the same time.  We now have a bigger problem,
> > though.  We have written code that communicates to a Tandem machine,
> > and to a SunOS machine using Berkeley sockets.  If we run the code
> > which was compiled and linked on the 3.2 machine (we kept one around
> > just in case), it runs just fine.  This same code also runs on the
> > SunOS side of the connection.  Communications are flawless.

> > The problem comes when we try to run the code which was compiled on
> > the 4.1 AIX machine.  We either get ECONNREFUSED or EACCESS errors
> > on the communications ports.

> You get ECONNREFUSED or EACCESS from *which* system call(s)?
> connect(2) and bind(2) respecively?  From the AIX 4.1.4 connect(2) and
> bind(2) man pages, these errors mean this:

Sorry for the long message, but I couldn't figure out a good place to
snip.  I get the errors from the connect() function.

The thing that seems to have been lost here (regarding the services
files, etc) is that if we compile the SAME code on a 3.2.5 machine,
it runs correctly on the 4.1.4 machine.  It is only when we try to
run that code after compilation on the 4.1.4 machine that we see
the errno indications.

I should also point out that IBM has not been particularly responsive
IMHO to this problem.  I have provided them with a complete, albeit
terse, program that will attempt to establish a socket connection.
I will provide that same code to anyone who wishes it.

--
R. Michael "Okie" Gillmore
Highway Transportation Electronics
OBC Office Software
Mail Stop 105-170
Phone: (319)295-5932


 
 
 

AIX 3.2 vs AIX 4.1 Implementation of Berkeley sockets

Post by Andrew Gabri » Sun, 27 Oct 1996 04:00:00


Some time ago, I also did a port from AIX3 to AIX4. I don't have
any of the sources or the machines handy right now, but I vaguely
recall having to #define compat_43 or something similar on AIX4.
Look in the socket header files for the exact name to #define -
this is from memory (might have been uppercase).

--


 
 
 

1. AIX 4.1 dependence on AIX 3.2 server

I am trying to make a client running AIX 4.1 independent from a server
running AIX 3.2 and don't fully understand what is causing the
dependence that still exists.  

Having removed NIS from both the server and client, I copied /etc/passwd
and /etc/security/passwd from the server to the client machine.
Everything seemed to be okay after reboots.  I used smit to rename the
server (because it lost /usr/local in a disk crash and I, a Solaris
manager, came into help out) and then used smit to change the NFS mounts
on both the server and client.  I then restored the DocumentRoot of the
website (it lost its httpd on /usr/local) on another webserver as a
virtual host (which is why I had to change the name of the AIX 3.2 server).

The problem that has now resulted is that users cannot now login to
either the server or the client (other than 'root').  Can anyone tell me
what other software AIX would be running that would cause this type of
dependence and possibly point me in the right direction to solve this?
Thanks a million.

Dave Robbins

2. *#&$ Realtek ethernet card...

3. AIX 3.2.5 vs AIX 4.1

4. Getting dip to hang up?

5. Malloc AIX 3.1 vs. AIX 3.2

6. optical jukebox

7. Need Z-modem for AIX 3.2 and 4.1 , Desperate !

8. Zaurus report part 1

9. AIX 3.2.x or 4.1.x

10. AIX 3.2.x oder 4.1.x

11. Can't run AIX 4.1 appliation n AIX 4.3.2

12. AIX 4.1 sendmail.cf to AIX 4.2 sendmail.cf

13. How to map CECP <-> AIX Code for tn3270 for AIX 3.2?