Use a JAVA program to obtain the IP address-general Linux technology-Linux programming and kernel information. The following is a detailed description. When using the TCP/IP Internet, you often need to query the IP address of your host and the IP address of the www server. Although we can use IPCONFIG and PING to Query IP addresses, if we use this command in an application or APPLET, we will destroy our application interface.
Therefore, a simple program using JAVA can directly query the IP addr
(): -str =Opener.read () + returnRe.search ('\d+\.\d+\.\d+\.\d+', str). Group (0) -Getmyip =Getmyip () +Localip =Getmyip.getip () A PrintLocalipGet System InformationThere's a platform module in Python that can get information about the operating system.Import PlatformPlatform.machine () # Returns the machine type, e.g. ' i386 'Platform.node () # Returns the computer ' s network namePlatform.platfo
Sub getmyip ()Dim strcomputer as stringDim ob1_mi as objectDim colip as objectDim IP as objectDim I as integer
Strcomputer = "."Set ob1_mi = GetObject ("winmgmts: //" strcomputer "/root/cimv2 ")Set colip = ob1_mi. execquery _("Select * From win32_networkadapterconfiguration where ipenabled = true ")For each IP in colipIf not isnull (IP. IPaddress) thenFor I = lbound (IP. IPaddress) to ubound (IP. IPaddress)Msgbox IP. IPaddress (I), vbinformation, I
1. obtain the Client IP address (this must be uploaded from the client to the backend): Under the jsp page, it is very simple, request. getRemoteAddr (); because the VIew layer of the system is implemented using JSF, the page cannot directly obtain similar requests, A forced conversion [java] public String getMyIP () {try {FacesContext fc = FacesContext is made in bean. getCurrentInstance (); HttpServletRequest request = (HttpServletRequest) fc. getEx
important:
Add between function Getmyip (){Suppose Window.document.form1.iptxt.value=window.document.getipapp.myip ();}
Note: Use JavaScript to treat the applet as a page element and provide simple communication to get the client IP address from the applet directly from the page and submit it to the server via the form (method slightly).
Now, what the client needs to do is install the JRE virtual machine (recommendation 1.4.1 above), and you will see
;}}function SysInfo ($Name) {//Get system Information$SQL = new MySQL ();$SQL->query ("select * from ' SysInfo ';");$SQL->nextrecord ();$TMP = $SQL->getrecord ($Name);$SQL->free ();return $TMP;}function Find_member ($name) {//Find the user (required for registration)$SQL = New MySQL ();$SQL->query ("select * from ' The Members ' WHERE ' username ' = ' $name ';");$RS = $SQL->rows ();$SQL->free ();if ($RS)return 1;Elsereturn 0;}function Str_safe ($STR) {//String security filtering$str = Str_replac
Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.InputStreamReader;
Import Java.io.LineNumberReader; public class Getmac {/** * Java gets the MAC address of the client network card * * @param args/public static void main (string[] args) {Ge
TMAC get = new Getmac ();
System.out.println ("1=" +get.getmac ());
System.out.println ("2=" +get.getmac ("127.0.0.1"));
//1. Get the client IP address (this must be uploaded from the client background)://
Most of the code on the Internet is outdated, so get ready to do it yourself. Get the data source
Http://ip.chinaz.com/getip.aspx
The effect is as follows:
The code is as follows:
public static string Getmyip () throws IOException {
string url= "http://ip.chinaz.com/getip.aspx";
InputStream is = new URL (URL). OpenStream ();
try {
BufferedReader rd = new BufferedReader (new InputStreamReader (IS, Charset.forname ("UTF-
, 192.168.1.100 user real IP: 192.168.1.1102008-04-02 16:59 recently made a security system, the user's IP and MAC address needs to be verified, here is used to obtain the client IP and MAC address of two methods, retained.1. Obtain the client IP address (this must be uploaded from the client to the backend):JSP page, very simple, request.getremoteaddr ();Because the view layer of the system is implemented in JSF, there is no direct access to the request on the page, and a cast is made in the be
This is a creation in
Article, where the information may have evolved or changed.
packagemainimport ("Flag" "FMT" "IO" "NET" "Net/http" "OS") Varget_ip=flag. String ("Get_ip", "", "External|internal") Funcmain () {fmt. Println ("usageof./getmyip--get_ip= (external|internal)") flag. Parse () if*get_ip== "external" {get_external ()}if*get_ip== "internal" {get_internal ()}}funcget_external () {resp,err:=http. Get ("Http://myexternalip.com/raw") Iferr!=ni
The use of dial-up Internet, there are generally a local IP and an extranet IP, using Python can easily get these two IPUse the gethostbyname and GETHOSTBYNAME_EX two functions to implement
The code is as follows
Copy Code
Import socketLocalip = Socket.gethostbyname (Socket.gethostname ()) #这个得到本地ipPrint "Local ip:%s"%localipIPList = SOCKET.GETHOSTBYNAME_EX (Socket.gethostname ())For I in IPList:If I!= localip:print "External ip:%s"%i
Get local IP Address
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.