Hi Tru64 colleagues!
As a followup to my posting of a bug we have found in the Tru64 5.0A TCP
stack...
Attached you will find a very simple server and client program that
demonstrates
the bug.
Hope this may be of some use to others who have encountered the same problem.
We (and one of our Tru64 customers) have sent the information (and this
code) to Compaq. Hopefully a patch will be forthcoming from Compaq Engr.
Instructions:
Compile both C programs, run the server program in the background and then run
the client program.
You will see the close() fail in the client.
Regards,
Jim
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <unistd.h>
# include <errno.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netdb.h>
int main( int argc, char * argv[] )
{
int fd;
struct sockaddr_in sin_there;
char buf[10];
unsigned char * host;
if ( (fd= socket( AF_INET, SOCK_STREAM, IPPROTO_IP )) < 0 )
{ printf( "socket() failed\n" ); return -1; }
memset( &sin_there, 0, sizeof(sin_there) );
host= (unsigned char *)&(sin_there.sin_addr);
sin_there.sin_family = AF_INET;
sin_there.sin_port = htons( 9000 );
host[0]= 127; host[1]= 0; host[2]= 0; host[3]= 1;
if ( connect( fd, (struct sockaddr*)&sin_there, sizeof( sin_there ) )
< 0 )
{ printf( "connect() failed\n" ); close( fd ); return -1; }
if ( write( fd, "HELLO", 6 ) != 6 )
{ printf( "write() failed\n" ); close( fd ); return -1; }
if ( read( fd, buf, 6 ) != 6 )
{ printf( "read() failed\n" ); close( fd ); return -1; }
if ( shutdown( fd, 2 ) )
{ printf( "shutdown() failed\n" ); close( fd ); return -1; }
/********************************************************************/
/* Here, the close call fails with errno EINVAL */
/********************************************************************/
if ( close( fd ) < 0 )
{
printf( "close() failed %s\n", strerror( errno ) );
return -1;
}
printf( "%s\n", buf );
return 0;
}
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <unistd.h>
# include <errno.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netdb.h>
int main( int argc, char * argv[] )
{
int fd;
int fdc;
struct sockaddr_in sin_here;
char buf[10];
if ( (fd= socket( AF_INET, SOCK_STREAM, IPPROTO_IP )) < 0 )
{ printf( "socket() failed\n" ); return -1; }
memset( &sin_here, 0, sizeof(sin_here) );
sin_here.sin_family = AF_INET;
sin_here.sin_addr.s_addr = INADDR_ANY;
sin_here.sin_port = htons( 9000 );
if ( bind( fd, (struct sockaddr *)&sin_here, sizeof(sin_here) ) )
{ printf( "bind() failed\n" ); close( fd ); return -1; }
if ( listen( fd, 5 ) < 0 )
{ printf( "listen() failed\n" ); close( fd ); return -1; }
if ( (fdc= accept( fd, NULL, NULL )) < 0 )
{ printf( "accept() failed\n" ); close( fd ); return -1; }
if ( read( fdc, buf, 6 ) != 6 )
{ printf( "read() failed\n" ); close( fdc ); close( fd ); return -1; }
if ( write( fdc, buf, 6 ) != 6 )
{ printf( "write() failed\n" ); close( fdc ); close( fd ); return -1; }
if ( close( fdc ) < 0 )
{ printf( "close() failed\n" ); return -1; }
if ( close( fd ) < 0 )
{ printf( "close() failed\n" ); return -1; }
return 0;
}
--------------------------------------------------------
FSC - Building Better Information Technology Solutions-
from the Production Floor to the Customer's Door.
--------------------------------------------------------
Jim Jennis, Technical Director for Commercial Systems
Fuentez Systems Concepts, Inc.
1 Discovery Place, Suite 2
Martinsburg, WV. 25401
USA
Phone: +001 (304) 263-0163 ext. 235
Fax: +001 (304) 263-0702
Email: jjennis_at_discovery.fuentez.com
jhjennis_at_shentel.net
WEB:
http://www.discovery.fuentez.com/
Received on Fri Jul 07 2000 - 13:39:00 NZST