reason. As you say, it is pretty straightforward if you know what you're
"Joseph M. Newcomer" <newcomer@flounder.com> ha scritto nel messaggio
news:98qeh4povnh91mvkr7k54jnb454jubib0l@4ax.com...
It is sad that the network stacks are still trapped in the 1970s, and we
never got
wgethostname and therefore _tgethostname.
I'm not expert in networking, so I could miss something, but it seems that
host names are expressed by ASCII characters:
RFC 952
http://www.faqs.org/rfcs/rfc952.html
RFC 1123
http://www.ietf.org/rfc/rfc1123.txt
I think that the correct way is what you showed above, using conversion to
CString.
It is a good Exercise-For-The-Reader (as you often write :) to wrap the
code you posted above in a function something like this:
<code>
CString GetHostName()
{
static const int maxChars = 256;
char hostname[ maxChars ];
gethostname( hostname, maxChars );
// ...may signal error using exceptions...
return CString( hostname ); // or use CA2T()
}
</code>
Giovanni