hostname

IP Address to Hostname in Java?

我只是一个虾纸丫 提交于 2019-11-26 16:27:21
问题 My hosts file (C:\WINDOWS\system32\drivers\etc\hosts) has a bunch of IP Address to host name mappings: # Switches 192.168.200.254 sw-con-ctrl 192.168.201.253 sw-con-ctrl-2 192.168.201.254 sw-con-ctrl-1 # 192.168.188.1 sw-con-ctrl-blk-1 # 192.168.189.1 sw-con-ctrl-red 192.168.190.62 access-console # Routers 192.168.21.1 rtr1 192.168.22.1 rtr2 I am trying to find a way to convert from an IPAddress to the HostName programmatically through Java APIs. Pseudocode: IPAddress ip = new IPAddress("192

How to get full host name + port number in Application_Start of Global.aspx?

时间秒杀一切 提交于 2019-11-26 09:38:43
问题 I tried Uri uri = HttpContext.Current.Request.Url; String host = uri.Scheme + Uri.SchemeDelimiter + uri.Host + \":\" + uri.Port; and it worked well on my local machine, but when being published to IIS7, there is an exception saying System.Web.HttpException: Request is not available in this context Anyone know how to achieve this? 回答1: When your web application starts, there is no HTTP request being handled. You may want to handle define the Application_BeginRequest(Object Sender, EventArgs e)

Java SSL: how to disable hostname verification

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 09:33:28
问题 Is there a way for the standard java SSL sockets to disable hostname verfication for ssl connections with a property? The only way I found until now, is to write a hostname verifier which returns true all the time. Weblogic provides this possibility, it is possible to disable the hostname verification with the following property: -Dweblogic.security.SSL.ignoreHostnameVerify 回答1: It should be possible to create custom java agent that overrides default HostnameVerifier : import javax.net.ssl.*;

Get hostname of current request in node.js Express

我只是一个虾纸丫 提交于 2019-11-26 08:49:30
问题 So, I may be missing something simple here, but I can\'t seem to find a way to get the hostname that a request object I\'m sending a response to was requested from. Is it possible to figure out what hostname the user is currently visiting from node.js? 回答1: If you're talking about an HTTP request, you can find the request host in: request.headers.host But that relies on an incoming request. More at http://nodejs.org/docs/v0.4.12/api/http.html#http.ServerRequest If you're looking for machine

How do I get the local machine name in C#?

人盡茶涼 提交于 2019-11-26 07:38:52
问题 How do I get the local machine name? 回答1: System.Environment.MachineName 回答2: You should be able to use System.Environment.MachineName for this. It is a property that returns a string containing the netBIOS name of the computer: http://msdn.microsoft.com/en-us/library/system.environment.machinename.aspx 回答3: From link text Four ways to get your local network/machine name: string name = Environment.MachineName; string name = System.Net.Dns.GetHostName(); string name = System.Windows.Forms

How can I use Python to get the system hostname?

和自甴很熟 提交于 2019-11-26 06:51:48
问题 I\'m writing a chat program for a local network. I would like be able to identify computers and get the user-set computer name with Python. 回答1: Use socket and its gethostname() functionality. This will get the hostname of the computer where the Python interpreter is running: import socket print(socket.gethostname()) 回答2: Both of these are pretty portable: import platform platform.node() import socket socket.gethostname() Any solutions using the HOST or HOSTNAME environment variables are not

Recommended way to get hostname in Java

自作多情 提交于 2019-11-26 03:23:15
问题 Which of the following is the best and most portable way to get the hostname of the current computer in Java? Runtime.getRuntime().exec(\"hostname\") vs InetAddress.getLocalHost().getHostName() 回答1: Strictly speaking - you have no choice but calling either hostname(1) or - on Unix gethostname(2) . This is the name of your computer. Any attempt to determine the hostname by an IP address like this InetAddress.getLocalHost().getHostName() is bound to fail in some circumstances: The IP address

Python lookup hostname from IP with 1 second timeout

孤街醉人 提交于 2019-11-26 02:56:19
问题 How can I look up a hostname given an IP address? Furthermore, how can I specify a timeout in case no such reverse DNS entry exists? Trying to keep things as fast as possible. Or is there a better way? Thank you! 回答1: >>> import socket >>> socket.gethostbyaddr("69.59.196.211") ('stackoverflow.com', ['211.196.59.69.in-addr.arpa'], ['69.59.196.211']) For implementing the timeout on the function, this stackoverflow thread has answers on that. 回答2: What you're trying to accomplish is called

How to extract the hostname portion of a URL in JavaScript

一曲冷凌霜 提交于 2019-11-26 00:49:32
问题 Is there a really easy way to start from a full URL: document.location.href = \"http://aaa.bbb.ccc.com/asdf/asdf/sadf.aspx?blah\" And extract just the host part: aaa.bbb.ccc.com There\'s gotta be a JavaScript function that does this reliably, but I can\'t find it. 回答1: suppose that you have a page with this address: http://sub.domain.com/virtualPath/page.htm . use the following in page code to achive those results: window.location.host : you'll get sub.domain.com:8080 or sub.domain.com:80

How to extract the hostname portion of a URL in JavaScript

巧了我就是萌 提交于 2019-11-25 23:17:30
Is there a really easy way to start from a full URL: document.location.href = "http://aaa.bbb.ccc.com/asdf/asdf/sadf.aspx?blah" And extract just the host part: aaa.bbb.ccc.com There's gotta be a JavaScript function that does this reliably, but I can't find it. Amin Saqi suppose that you have a page with this address: http://sub.domain.com/virtualPath/page.htm . use the following in page code to achive those results: window.location.host : you'll get sub.domain.com:8080 or sub.domain.com:80 window.location.hostname : you'll get sub.domain.com window.location.protocol : you'll get http: window