[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference lassie::ucx

Title:DEC TCP/IP Services for OpenVMS
Notice:Note 2-SSB Kits, 3-FT Kits, 4-Patch Info, 7-QAR System
Moderator:ucxaxp.ucx.lkg.dec.com::TIBBERT
Created:Thu Nov 17 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:5568
Total number of notes:21492

5550.0. "EACCESS returned by connect - very misleading" by CSC32::J_HENSON (Don't get even, get ahead!) Thu May 29 1997 11:44

ucx 3.3 eco 9, ovms v5.5-2h4, vax, socket i/f

I have found what appears to be a very misleading error code returned
from connect.  In this case, a EACCESS - permission denied error
is returned.  This is not even one of the errors that the programming
manual lists as a possible return code.

However, Chapter 8 cross-references eaccess to ss$_abort, and ss$_abort
is documented as a possible error returned from $qio/io$_access.  Among
other things, this could be caused by a programming error.  In the
case I have been working, I believe it is being returned by a bad
value in the address structure.

Would it be possible for engineering to look at this and make the
documentation clearer, or change the error code being returned to
be a bit more helpful?  I've spent about 2 hours chasing this down,
and my customer has lost about 2 days because of this.

For an example of what I mean, refer to the next reply.  It contains
a program sample AND error log output.  I believe that the error is
caused by improper use of the inet_addr routine, but it's not
obvious from the errors being logged.

Thanks,

Jerry
T.RTitleUserPersonal
Name
DateLines
5550.1sample codeCSC32::J_HENSONDon't get even, get ahead!Thu May 29 1997 11:54497
Here's the information as I received it from the customer.  I believe
(but haven't thoroughly tested.  I hate debugging customer's code for
free) that the original error stems from improper use of inet_addr.
He is passing in the string 'jla.pont.cat.com' instead of the numeric
equivalent.  From my testing, this should result in a -1 being
returned instead of a valid int address.

There may be other errors in the code, but I quit when I discovered
this.  Anyway, I'm posting this mainly to illustrate the point I
am trying to make.

Jerry

=================================================================
$ ucx show version                                                              
                                                                                
  DEC TCP/IP Services for OpenVMS VAX Version V3.3 - ECO Level 9                
  on a VAX 4000-500A running OpenVMS V5.5-2H4                                   
                                                                                
$ sh sys                                                                        
                                                                                
VAX/VMS V5.5-2H4  on node PONT19  27-MAY-1997 09:07:59.32   Uptime  58          
01:54:02                                                                        
                                                                                
                                                                                
$ ucx show services                                                             
                                                                                
Service             Port  Proto    Process          Address            State    
                                                                                
BIND                  53  TCP,UDP  UCX$BIND         0.0.0.0                     
Disabled                                                                        
FTP                   21  TCP      UCX$FTPD         0.0.0.0                     
Enabled                                                                         
LPD                  515  TCP      UCX$LPD          0.0.0.0                     
Enabled                                                                         
MOUNT                 10  UDP      UCX$NFS          0.0.0.0                     
Disabled                                                                        
NFS                 2049  UDP      UCX$NFS          0.0.0.0                     
Disabled                                                                        
REXEC                512  TCP      UCX$REXECD       0.0.0.0                     
Enabled                                                                         
RLOGIN               513  TCP      not defined      0.0.0.0                     
Enabled                                                                         
RSH                  514  TCP      UCX$RSHD         0.0.0.0                     
Enabled                                                                         
SMTP                  25  TCP      UCX$SMTP         0.0.0.0                     
Enabled                                                                         
SNMP                 161  UDP      UCX$SNMP         0.0.0.0                     
Disabled                                                                        
TELNET                23  TCP      not defined      0.0.0.0                     
Enabled                                                                         
                                                                                
the system pont19 is trying to get to:                                          
                                                                                
$ ucx ping jla.pont.cat.com                                                     
%UCX-I-LOOPACT, jla.pont.cat.com is alive                                       
                                                                                
(jla is an nt v4.0 host)                                                        
                                                                                
$  nslookup jla.pont.cat.com                                                    
                                                                                
Server:  ike.pont.cat.com                                                       
Address:  137.230.82.3                                                          
                                                                                
Name:    jla.pont.cat.com                                                       
Address:  137.230.80.215                                                        
                                                                                
                                                                                
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()  
                                                                                
Source:                                                                         
                                                                                
                                                                                
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()  
                                                                                
/*****************************************************************************  
**                                                                              
*                                                                               
*	File:	 HI90_SOCKET.c                                                          
*	Title	 Client HI90 socket interface                                           
*                                                                               
*-------------------------/ Description                                         
/---------------------------------------                                        
*                                                                               
*	This example creates a socket of type SOCK_STREAM (TCP),                      
*	initiates a connection to the remote host, sends                              
*	a message to the remote host, and closes the connection.                      
*	Error messages are printed to the screen.                                     
*                                                                               
*	IPC calls used:                                                               
*	close                                                                         
*	connect                                                                       
*	gethostbyname                                                                 
*	recv                                                                          
*	shutdown                                                                      
*	socket                                                                        
*                                                                               
*                                                                               
* Formal Parameters                                                             
*	The client program expects two parameters:                                    
*	hostname ... name of remote host                                              
*	portnumber ... port where remote host(server) is listening                    
******************************************************************************  
*/                                                                              
                                                                                
#ifdef VMS                                                                      
#include  <errno.h>                                                             
#include  <types.h>                                                             
#include  <stdio.h>                                                             
#include  <socket.h>                                                            
#include  <in.h>                                                                
#include  <netdb.h>		/* change hostent to comply with BSD 4.3*/                 
#include  <inet.h>                                                              
#include  <ucx$inetdef.h>	/* INET symbol definitions */                         
#else                                                                           
#include <errno.h>                                                              
#include <sys/types.h>                                                          
#include <stdio.h>                                                              
#include <sys/socket.h>                                                         
#include <netinet/in.h>                                                         
#include <netdb.h>                                                              
#include <arpa/inet.h>                                                          
#include <sys/uio.h>                                                            
#endif                                                                          
#include "gstd.h"                                                               
#include "itim.h"                                                               
#include "iamu.h"                                                               
#include "hi90_pull.h"                                                          
                                                                                
                                                                                
#include "mloc.h"                                                               
#include "minv.h"                                                               
#include "pull.h"                                                               
                                                                                
#include "mdsm_msg.h"                                                           
#include "mrtn.h"                                                               
                                                                                
/*                                                                              
*                                                                               
*   MACRO DEFINITIONS                                                           
*                                                                               
*/                                                                              
                                                                                
#ifndef vms                                                                     
#define TRUE 1                                                                  
#define FALSE 0                                                                 
#endif                                                                          
                                                                                
/*                                                                              
* Functional Description                                                        
*                                                                               
*                                                                               
* Routine Value                                                                 
*                                                                               
*	Status                                                               
*/                                                                              

/*--------------------------------------------------------------------*/        
#define PGMNAME "hi90_socket"                                                   
hi90_socket(                                                                    
        int  argc,                                                              
	char *argv[])	/* argv[0] = Image Name */                                       
MAIN_PROGRAM                                                                    
{                                                                               
/* static  char  	message1[] = "Hi there."; */                                  
static 	struct  sockaddr_in sock2_name,cli_addr;    	/* Address struct for      
socket2.*/                                                                      
struct  hostent         hostentstruct;  /* Storage for hostent data.  */        
struct  hostent         *hostentptr;    /* Pointer to hostent data.   */        
static  char            hostname[256];  /* Name of local host.        */        
int	flag;                                                                       
int	retval;				/* helpful for debugging */                                      
int	e_ret_status;				/* helpful for debugging */                                
int     sock_1;                                                                 
bool	no_error;				/* helpful for debugging */                                   
int	shut = FALSE;			/* flag to cleanup */                                       
int     netaddr;                                                                
int i;                                                                          
PART ps_part;		/* POINTER TO PART STRUCTURE */                                  
object o_ptr;                                                                   
static struct HI90_PULL$STRUCT pull_message;	/* part structure */               
                                                                                
                                                                                
/*----------------------------------/ Code                                      
/----------------------------------*/                                           
                                                                                
/*****************************************************************************  
*/                                                                              
/*******************************  Initialization                                
*****************************/                                                  
/*****************************************************************************  
*/                                                                              
                                                                                
MINIT;                                                                          
                                                                                
minv_shr$open();		/* Open Inventory (Part) Shared Memory */                     
TRACE(PGM,"Argument Count = %d", argc);                                         
for (i=0; i<argc; i++)                                                          
    {                                                                           
    TRACE(PGM,"Argument Value %d is %s", i, argv[i]);                           
    }                                                                           
                                                                                
/* Set up Transaction Processing Environment */                                 
                                                                                
                                                                                
	/*                                                                             
	 * Check input parameters.                                                     
	 */                                                                            
	if (argc != 5)                                                                 
		{                                                                             
	        gmsg$warning("Incorrect number of arguments");                         
		exit();                                                                       
		}                                                                             
                                                                                
                                                                                
	/*                                                                             
	 * Open socket 1: AF_INET, SOCK_STREAM.                                        
	 */                                                                            
        if ((sock_1 = socket (AF_INET, SOCK_STREAM, 0)) == -1)                  
		{                                                                             
	        gmsg$warning("Socket creat error");                                    
		exit();                                                                       
                }                                                               
	/*                                                                             
	 *Get pointer to network data structure for socket 1 (remote host).            
	 */                                                                            
        cli_addr.sin_family = AF_INET;                                          
        cli_addr.sin_addr.s_addr = INADDR_ANY;                                  
        cli_addr.sin_port = 0;                                                  
        if (bind(sock_1, &cli_addr, sizeof(cli_addr)) == -1)                    
                {                                                               
                perror("bind");                                                 
		cleanup(shut, sock_1);                                                        
	        gmsg$warning("bind error");                                            
                }                                                               
        if ((hostentptr = gethostbyname (argv[2])) == NULL)                     
		{                                                                             
                perror ("gethostbyname");                                       
                TRACE(PGM,"hostentptr = %d argv[2]=%s ", hostentptr, argv[2]);  
		cleanup(shut, sock_1);                                                        
	        gmsg$warning("gethostbyaddr error");                                   
		}                                                                             
        TRACE(PGM,"hostentptr value = %d ", hostentptr);                        
                                                                                
	/*                                                                             
	 * Copy hostent data to safe storage.                                          
	 */                                                                            
        hostentstruct = *hostentptr;                                            
                                                                                
                                                                                
	/*                                                                             
	 * Fill in the name & address structure for socket 2.                          
	 */                                                                            
        sock2_name.sin_family = AF_INET;                                        
        sock2_name.sin_addr.s_addr = inet_addr(argv[2]);                        
	sock2_name.sin_port = htons(atoi(argv[3]));                                    
                                                                                
                                                                                
	/*                                                                             
	 * Connect socket 1 to sock2_name.                                             
	 */                                                                            
        while (TRUE)                                                            
           {                                                                    
	   retval = connect(sock_1, &sock2_name, sizeof (sock2_name));                 
           TRACE(PGM,"connect retval = %d ", retval);                           
           TRACE(PGM,"connect sock1 = %d ", sock_1);                            
	   if (retval == FALSE)                                                        
	      {                                                                        
	      /*                                                                       
	       * Receive message from socket 1.                                        
	      */                                                                       
	      flag = 0;	/* maybe 0 or MSG_OOB */                                       
              no_error = TRUE;                                                  
              while (no_error)                                                  
                 {                                                              
	         retval = recv(sock_1, pull_message.pn ,sizeof (pull_message), flag);  
                 TRACE(PGM,"receive retval = %d ", retval);                     
	         if (retval > 0)                                                       
		    {                                                                         
                    TRACE(PGM,"Part Number = %s ", pull_message.pn);            
                    ps_part = minv_part$select(pull_message.pn);                
                    e_ret_status = minv_tray$modify_loc(&pull_message.tray_id,  
				                        NULL,                                               
				                        MLOC_C_CAT_CD_FLR,                                  
				                        NULL,                                               
				                        MLOC_C_CAT_CD_ASRS,                                 
				                        NULL);                                              
                    minv_part$reorder(ps_part);                                 
		    }                                                                         
                 else                                                           
                    {                                                           
                    perror("recv");                                             
                    retval = close (sock_1);                                    
                    no_error = FALSE;                                           
                    }                                                           
                 }                                                              
              }                                                                 
           else                                                                 
              {                                                                 
              perror("connect");                                                
              sleep(10);                                                        
              }                                                                 
           }                                                                    
     /*                                                                         
     * Call cleanup to shutdown and close socket.                               
     */                                                                         
       cleanup(shut, sock_1);                                                   
       exit();                                                                  
                                                                                
 } /* end main */                                                               
                                                                                
/*-----------------------------------------------------------*/                 
                                                                                
cleanup(int shut, int socket)                                                   
                                                                                
{                                                                               
	int	retval;                                                                    
                                                                                
	/*                                                                             
	 * Shutdown socket completely -- only if it was connected                      
	 */                                                                            
	if (shut) {                                                                    
		retval = shutdown(socket,2);                                                  
	}                                                                              
                                                                                
                                                                                
	/*                                                                             
	 * Close socket.                                                               
	 */                                                                            
        retval = close (socket);                                                
	if (retval)                                                                    
                                                                                
        minv_shr$close();                                                       
                                                                                
 } /* end main */                                                               
                                                                                
                                                                                
                                                                                
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()  
                                                                                
Now the log excerpt...                                                          
                                                                                
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()  
                                                                                
                                                                                
$ THRUWAY :== $THRUWAY                                                          
$ oncall :== sho log Vax_support_person_on_call_is                              
$        IF "OTHER" .EQS. "NETWORK" THEN EXIT                                   
$ IF  F$MODE() .NES. "INTERACTIVE"                                              
$ then                                                                          
$ SAVE_VERIFY = F$Verify(0)                                                     
NOW EXECUTING SYSTEM LOGIN FILE                                                 
COMPLETED EXECUTING SYSTEM LOGIN FILE                                           
$ else                                                                          
$ endif                                                                         
$ EXIT:                                                                         
$	EXIT                                                                          
$ !                                                                             
$ ! [bef]login.com                                                              
$ !                                                                             
$ !set display/create/node=flatt.pont.cat.com/tranport=tcpip                    
$ !                                                                             
$ if f$mode() .eqs. "OTHER"                                                     
$ then                                                                          
$   @mod$com:LOGIN.COM DHIPBEF                                                  
$ save_verify = f$verify(0)                                                     
$ exit	! mod$com:login.com                                                      
$   goto endbatch                                                               
$ENDBATCH:                                                                      
$   EXIT                                                                        
$ set verify                                                                    
$ !                                                                             
$ ! Filename: START_PROC.COM                                                    
$ !                                                                             
$ ! COMMAND PROCEDURE TO INVOKE A Cell Control PROCESS IN DETACHED PROCESS      
MODE                                                                            
$                                                                               
!-----------------------------------------------------------------------------  
-                                                                               
$ !                                                                             
$ !                                                                             
$ ! Extract process name from the system and lookup corresponding               
$ ! ITRN Transaction Processing Key.                                            
$ !                                                                             
$ PROC_NAME = F$PROCESS()                                                       
$ on error then goto log_process                                                
$ on severe_error then goto log_process                                         
$ show symbol proc_name                                                         
  PROC_NAME = "DHIP_HI90"                                                       
$ TPKEY = F$LOGICAL("DHIP_HI90")                                                
$ show symbol tpkey                                                             
  TPKEY = "53"                                                                  
$ show symbol proc_name                                                         
  PROC_NAME = "DHIP_HI90"                                                       
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_LOGGER"                                              
$ endif                                                                         
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_IAMU"                                                
$ endif                                                                         
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_RECSYN"                                              
$ endif                                                                         
$ !                                                                             
$ if f$extract(f$length(system_prefix),6,proc_name) .eqs. "_TPMAN"              
$ endif                                                                         
$ !                                                                             
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_BBN1"                                                
$ endif                                                                         
$ IF PROC_NAME .EQS. "DHIP_BBN2"                                                
$ endif                                                                         
$ IF PROC_NAME .EQS. "DHIP_BBN3"                                                
$ endif                                                                         
$ IF PROC_NAME .EQS. "DHIP_BBN4"                                                
$ endif                                                                         
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_GDCI" THEN -                                         
				proc_image = "$hip_bld:gdci_main.exe"                                       
$ IF PROC_NAME .EQS. "DHIP_MAGV" THEN -                                         
				proc_image = "$hip_bld:magv_main.exe"                                       
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_MASY"                                                
$ endif                                                                         
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_MMOV" THEN -                                         
	proc_image = "$hip_bld:mmov_main.exe"                                          
$ IF PROC_NAME .EQS. "DHIP_MASR" THEN -                                         
	proc_image = "$hip_bld:masr_main.exe"                                          
$ IF PROC_NAME .EQS. "DHIP_MASR1"                                               
$	endif                                                                         
$ IF PROC_NAME .EQS. "DHIP_MASR2"                                               
$	endif                                                                         
$ IF PROC_NAME .EQS. "DHIP_MCNV"                                                
$ 	endif                                                                        
$ !                                                                             
$ if f$extract(f$length(system_prefix),5,proc_name) .eqs. "_FLPN"               
$ 	endif                                                                        
$ !                                                                             
$ ! Data Concentrator Processes                                                 
$ !                                                                             
$ IF PROC_NAME .EQS. "DHIP_DC_UHR"                                              
$ ENDIF                                                                         
$ IF PROC_NAME .EQS. "DHIP_DC_URR" THEN -                                       
					proc_image = "$hip_bld:dc_urr.exe"                                         
$ IF PROC_NAME .EQS. "DHIP_DC_PPC" THEN -                                       
					proc_image = "$hip_bld:dc_ppc.exe"                                         
$ IF PROC_NAME .EQS. "DHIP_DC_RWC" THEN -                                       
					proc_image = "$hip_bld:dc_rwc.exe"                                         
$ IF PROC_NAME .EQS. "DHIP_DC_APP" THEN -                                       
					proc_image = "$hip_bld:dc_app.exe"                                         
$ IF PROC_NAME .EQS. "DHIP_DC_PLC" THEN -                                       
					proc_image = "$hip_bld:dc_plc.exe"                                         
$ !                                                                             
$ show symbol proc_name                                                         
  PROC_NAME = "DHIP_HI90"                                                       
$ show symbol tpkey                                                             
  TPKEY = "53"                                                                  
$ DEFINE/USER/TABLE=LNM$PROCESS_DIRECTORY LNM$TEMPORARY_MAILBOX LNM$GROUP       
$ if f$extract(f$length(system_prefix),6,proc_name) .eqs. "_HI90"               
$ then                                                                          
$	proc_image = "$hip_bld:hi90_socket.exe"                                       
$       proc_image DHIP_HI90 "jla.pont.cat.com" "12014" 53                      
%TRACE, 23-MAY 11:52:05 hi90_socket begin                                       
%TRACE, 23-MAY 11:52:05 hi90_socket Argument Count = 5                          
                                                                                
%TRACE, 23-MAY 11:52:05 hi90_socket Argument Value 0 is                         
$1$dia8:[dhip.][bld_v4.                                                         
work]hi90_socket.exe;18                                                         
                                                                                
%TRACE, 23-MAY 11:52:05 hi90_socket Argument Value 1 is dhip_hi90               
%TRACE, 23-MAY 11:52:05 hi90_socket Argument Value 2 is jla.pont.cat.com        
%TRACE, 23-MAY 11:52:05 hi90_socket Argument Value 3 is 12014                   
%TRACE, 23-MAY 11:52:05 hi90_socket Argument Value 4 is 53                      
%TRACE, 23-MAY 11:52:06 hi90_socket hostentptr value = 12232688                 
%TRACE, 23-MAY 11:52:06 hi90_socket connect retval = -1                         
%TRACE, 23-MAY 11:52:06 hi90_socket connect sock1 = 3                           
                                                                                
connect: permission denied                                                      
                                                                                
%TRACE, 23-MAY 11:52:16 hi90_socket connect retval = -1                         
%TRACE, 23-MAY 11:52:16 hi90_socket connect sock1 = 3                           
connect: address already in use                                                 
%TRACE, 23-MAY 11:52:26 hi90_socket connect retval = -1                         
%TRACE, 23-MAY 11:52:26 hi90_socket connect sock1 = 3                           
connect: address already in use                                                 
%TRACE, 23-MAY 11:52:36 hi90_socket connect retval = -1                         
%TRACE, 23-MAY 11:52:36 hi90_socket connect sock1 = 3                           
connect: address already in use                                                 
%TRACE, 23-MAY 11:52:46 hi90_socket connect retval = -1                         
%TRACE, 23-MAY 11:52:46 hi90_socket connect sock1 = 3                           
connect: address already in use                                                 
                                                                                
.                                                                               
.                                                                               
.                                                                               
.