CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    GetComputerName on Solaris

    Hello,

    Is there any function what retrieves name of computer the application is running on?

    Thanks

  2. #2
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    Lookup the man page on uname.
    Succinct is verbose for terse

  3. #3
    Join Date
    Mar 2002
    Posts
    350
    int gethostname(char *name, int namelen);

  4. #4
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    The Windows Sockets gethostname function returns the standard host name for the local machine.
    Strait out of MSDN! Hes not running on Windows, and therefore does not have Winsock.

  5. #5
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    Originally posted by mwilliamson


    Strait out of MSDN! Hes not running on Windows, and therefore does not have Winsock.
    gethostname() is available on many systems, not just Windows.
    It's available on many unix systems:

    http://www.mcsr.olemiss.edu/cgi-bin/...?gethostname+2

  6. #6
    Join Date
    May 2002
    Location
    Germany
    Posts
    451
    Okay, thank you gentlemen (or gentlewomen)

    I got it. I did not want to link sockets stuff on Solaris (as I do not link winsock for GetComputerName, just MFC).

    Is there a chance to get the computer name w/o the socket stuff?

  7. #7
    Join Date
    Mar 2002
    Posts
    350
    uname will not work on old unix systems ,there for gethostname will be the best solution

  8. #8
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    uname will work from Solaris 2.6 onwards. Don't know about 2.5. On 2.6, because gethostname was a BSD thing, you will need to declare it explicitly as it is not included in any header file. Well, that's my penny's worth - things may have changed on later versions of Solaris: I think it is now on 2.9.
    Succinct is verbose for terse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured