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
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;
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 );