ip-address

Convert signed int to string ip address in SQL Server

旧城冷巷雨未停 提交于 2019-12-04 10:09:35
I'm retrieving a signed int from a SQL Server database and need to convert it to a "normal" looking dotted string for display to users. Googling, I found this code: SELECT dbo.IPADDRESS.IPADDRESS, CAST(ROUND( (cast(dbo.IPADDRESS.IPADDRESS as bigint) / 16777216 ), 0, 1) AS varchar(4)) + '.' + CAST((ROUND( (cast(dbo.IPADDRESS.IPADDRESS as bigint) / 65536 ), 0, 1) % 256) AS varchar(4)) + '.' + CAST((ROUND( (cast(dbo.IPADDRESS.IPADDRESS as bigint) / 256 ), 0, 1) % 256) AS varchar(4)) + '.' + CAST((cast(dbo.IPADDRESS.IPADDRESS as bigint) % 256 ) AS varchar(4)) as IPDottedNotation FROM dbo.IPADDRESS

Some doubts about how to retrieve multiple IP addresses (if I have more than one network card) in Java?

烂漫一生 提交于 2019-12-04 09:49:28
I have the following 2 problems in retrieving the ip of a client. I have create the following code inside a class: private static InetAddress thisIp; static{ try { thisIp = InetAddress.getLocalHost(); System.out.println("MyIp is: " + thisIp); } catch(UnknownHostException ex) { } } My problems are: 1) The previous code should retrieve the IP address of a client, when I execute it it print the following message: MyIp is: andrea-virtual-machine/127.0.1.1 Why it begin with andrea-virtual-machine/ ? (I am developing on a virtual machine), is it a problem? 2) In this way I can retrieve only a single

golang force http request to specific ip (similar to curl --resolve)

不羁岁月 提交于 2019-12-04 09:09:42
问题 How can I force a golang https get request to use a specific IP address. I want to skip DNS resolution and provide the IP myself. The equivalent in curl would be a --resolve as illustrated below. curl https://domain.com/dir/filename --resolve "domain.com:443:10.10.10.10" Since this is ssl I want to avoid substituting in the IP for the domain as in the following example. curl https://10.10.10.10/dir/filename --header "Host: domain.com" 回答1: You can provide a custom Transport.DialContext

Java Getting IPv4 Address

淺唱寂寞╮ 提交于 2019-12-04 07:42:27
Regarding this link where using the codes provided to produce the IP addresses. String ip; try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface iface = interfaces.nextElement(); // filters out 127.0.0.1 and inactive interfaces if (iface.isLoopback() || !iface.isUp()) continue; Enumeration<InetAddress> addresses = iface.getInetAddresses(); while(addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); ip = addr.getHostAddress(); System.out.println(iface.getDisplayName() + " " + ip); }

How do I increment an IP address represented as a string?

馋奶兔 提交于 2019-12-04 06:41:24
I have an IP address in char type Like char ip = "192.123.34.134" I want increment the last value (134). Does anyone how should i do it? I think, i should convert it to an integer, and then back, but unfortunately i don't know how? :( I'm using C++. Please help me! Thanks, kampi You can convert the IP address from a string to an integer using inet_addr , then, after manipulating it, convert it back to a string with inet_ntoa . See the documentation for these functions for more info on how to use them. Here's a small function that will do what you want: // NOTE: only works for IPv4. Check out

How to get ip address, referer, and user agent in ruby?

烈酒焚心 提交于 2019-12-04 06:23:37
I want to log user's ip address, referer, and user agent. In PHP, I can get them from the following variables: $_SERVER['REMOTE_ADDR'] $_SERVER['HTTP_REFERER'] $_SERVER['HTTP_USER_AGENT'] How to get them in ruby? timaschew You need the array request.env request.env['REMOTE_ADDR']: PHP is embedded in a web server. Ruby is a general-purpose language: if you need a web server context, you'll have to install it yourself. Fortunately, it's easy. One of the easiest ways to get started is with Sinatra . Install the gem: gem install sinatra Then create myapp.rb: require 'sinatra' get '/' do request

What is the Windows XP equivalent of inet_pton or InetPton?

一曲冷凌霜 提交于 2019-12-04 05:47:52
I need to determine whether a particular string is a valid IPv4 or IPv6 address literal. If I understand correctly, the correct way to do this on POSIX systems is to use inet_pton to convert it into a network address structure and see if it succeeds. Windows Vista and later have InetPton which does essentially the same thing. But as far as I can tell, Windows XP doesn't declare either of those, and I need to be able to do this correctly on XP. So, the question is what system function to use to do this? Worst case, I can write a function to parse it myself, but I'd prefer a standard, system

Get the IPaddress of the computer in an Android project using java

亡梦爱人 提交于 2019-12-04 05:42:14
I am using ksoap2-android and i need to get the IP address using java so that I don't have to type it manually everytime. What i mean by IP address is , for example if I do ipconfig using the command shell: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : f0::ed2:e3bf:8206:44%13 IPv4 Address. . . . . . . . . . . : 192.168.1.107 <--THIS ONE Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 The thing is am developing an android app, and the emulator has a different type of IP's than the machine's . I need to get the machine's

How to find location based on IP address in Excel

拟墨画扇 提交于 2019-12-04 04:58:51
I've got a spreadsheet of about 5000 user events associated with IPs, and I'm trying to use IP to determine location using just an Excel formula. The IPs in my log are structured as "dotted quads" (decimal notation). I figured VLOOKUP is the way to go here, so I downloaded WEBNet77's IPV4 IpToCountry database , which seems like a comprehensive and up-to-date resource (is there a better resource out there for this purpose?). The database includes about 140K rows of IP ranges, with the sheet structured like so: Colum labels A - G are, respectively: IP FROM, IP TO, REGISTRY, ASSIGNED, CTRY, CNTRY

ip address of request from httpheader

喜欢而已 提交于 2019-12-04 03:58:12
I am trying to get the IP address of the request coming in from the httpheader. If value is x do something, if not do somthing else. Can anyone help me out? You might want to look here . The HTTP standards do not define the source address as part of the protocol. Infact HTTP does not directly relate to IPv4 /IPv6 at all. Generally, a webserver will easily be able to tell the network address of the other end of the socket ( the end where the web browser is ). It does not use HTTP to do this, rather it will use features of the OS's networking stack. In the case of ASP.NET you should be able to