home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / TTCP_SDK / hostname / hostname.c next >
Encoding:
C/C++ Source or Header  |  1996-07-28  |  982 b   |  52 lines

  1. /*
  2.  * This program prints the hostname of your computer.
  3.  *
  4.  * The hostname is the internet address assigned to your
  5.  * computer while you are connected to your service provider.
  6.  *
  7.  * This is a good demonstration of how programs can be written to
  8.  * conditionally take advantage of both TCP stacks.
  9.  *
  10.  */
  11.  
  12. #include <proto/tsocket.h>
  13. #include <pragmas/tsocket_pragmas.h>
  14.  
  15. #include <exec/libraries.h>
  16. #include <proto/exec.h>
  17. #include <stdio.h>
  18.  
  19.  
  20.  
  21. struct Library *TSocketBase;
  22.  
  23.  
  24.  
  25.  
  26. int main()
  27. {
  28.     char hostname[256];    
  29.  
  30.  
  31.     if ( !(TSocketBase = OpenLibrary("tsocket.library", 0)) )
  32.     {
  33.         printf("TermiteTCP is not running.\n");
  34.         return 10;
  35.     }
  36.  
  37.     printf("\nUsing: %s\n", TSocketBase->lib_IdString);
  38.  
  39.  
  40.     gethostname(hostname, sizeof(hostname));
  41.     printf("host name is \"%s\"\n\n", hostname);
  42.  
  43.     if ( hostname[0] == NULL )
  44.         printf("(TCP stack is probably not connected to service provider.)\n\n");
  45.  
  46.  
  47.     CloseLibrary(TSocketBase);
  48.  
  49.  
  50.     return 0;
  51. }
  52.