|
-
February 3rd, 2003, 11:04 AM
#1
GetComputerName on Solaris
Hello,
Is there any function what retrieves name of computer the application is running on?
Thanks
-
February 4th, 2003, 01:43 PM
#2
Lookup the man page on uname.
Succinct is verbose for terse
-
February 5th, 2003, 07:54 AM
#3
int gethostname(char *name, int namelen);
-
February 5th, 2003, 07:09 PM
#4
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.
-
February 5th, 2003, 08:51 PM
#5
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
-
February 6th, 2003, 03:53 AM
#6
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?
-
February 6th, 2003, 04:47 AM
#7
uname will not work on old unix systems ,there for gethostname will be the best solution
-
February 6th, 2003, 07:00 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|