Hostname: Difference between revisions

added haskell, not tested
(added haskell, not tested)
Line 27:
{{works with|gcc|4.0.1}}
{{works with|POSIX|.1}}
<c>#include <limits.h>
#include <unistd.h>
 
int main()
{
char name[_POSIX_HOST_NAME_MAX+1];
gethostname(name, _POSIX_HOST_NAME_MAX+1);
return 0;
}
}</c>
 
=={{header|C sharp|C#}}==
<csharp>System.Net.Dns.GetHostName();</csharp>
 
=={{header|Factor}}==
host-name
 
=={{header|Haskell}}==
{{libheader|network}}
import Network.BSD
main = do hostName <- getHostName
putStrLn hostName
 
=={{header|IDL}}==
Line 47 ⟶ 54:
=={{header|Java}}==
 
<java>String hostname = java.net.InetAddress.getLocalHost().getHostName();</java>
 
=={{header|OCaml}}==
Line 55 ⟶ 62:
{{works with|Perl|5.8.6}}
{{libheader|Sys::Hostname}}
<perl>use Sys::Hostname;
 
$name = hostname;</perl>
 
=={{header|PHP}}==
<php>echo $_SERVER['HTTP_HOST'];</php>
 
=={{header|Pop11}}==
Line 67 ⟶ 74:
=={{header|Python}}==
{{works with|Python|2.5}}
<python>import socket
host = socket.gethostname()</python>
 
=={{header|Tcl}}==
Anonymous user