home *** CD-ROM | disk | FTP | other *** search
- /* This program will list all open sockets in the Novell NetWare shell.
-
- This is done (inelegantly) by attempting to open each socket, then examining
- the the function result. If the result code is 0, the socket was opened,
- meaning the socket was not previously opened. If the result is 0xff, the
- socket was already open. A function result of 0xfe means the socket table
- is full, and the program cannot continue.
-
- Andy Stevens
- September 1, 1987
-
- */
-
-
-
-
- #define SWAP( x ) ( (x >> 8) | (x << 8) )
- /* all references, other than in an Event Control Block, must be in hi-low
- order, rather than the iAPX86 native hi-low order. This macro simply
- switches the hi and low order bytes of a two byte word. */
-
- unsigned count = 0, total = 0;
-
- void close_socket( unsigned socket )
- {
- _BX = 1;
- _DX = SWAP( socket );
- __int__( 0x7A );
- }
-
- void check_socket( unsigned socket )
- {
- _AL =
- _BX = 0;
- _DX = SWAP( socket );
- __int__( 0x7A );
- switch( _AL ) {
- case 0 : { /* socket not previously opened */
- close_socket( socket );
- break;
- }
- case 0xFF : { /* opened socket */
- printf("\tSocket: %4X\n", count);
- total++;
- break;
- }
- case 0xFE : { /* unable to continue */
- printf("ERROR - SOCKET TABLE IS FULL");
- exit( 1 );
- break;
- }
- }
- }
-
-
-
- main( void )
- {
- printf( "\nChecking for open sockets...\n" );
- printf( "(all sockets displayed in hex)\n\n" );
-
- for( count=0; count != 65535; count++ )
- check_socket( count );
-
- printf( "\nTotal open sockets: %d\n", total );
- }