Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2b6f88e

Browse files
Network Programming basic
1 parent cb20f24 commit 2b6f88e

File tree

3 files changed

+73
-44
lines changed

3 files changed

+73
-44
lines changed

‎.idea/workspace.xml

Lines changed: 48 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.5 KB
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.hello_world_package;
2+
3+
import java.net.InetAddress;
4+
5+
6+
public class Network_Programming_1 {
7+
public static void main(String[] args) throws java.net.UnknownHostException {
8+
9+
InetAddress inetAddress = InetAddress.getLocalHost();
10+
11+
//Let's see the local host name and IP address of our computer
12+
System.out.println("Our computer's name and IP address are "+ inetAddress);
13+
14+
//Let's see the IP address of a website
15+
16+
InetAddress addressName = InetAddress.getByName("facebook.com");
17+
System.out.println("The IP address of facebook.com is "+addressName);
18+
19+
InetAddress in[] = InetAddress.getAllByName("gmail.com"); //returns all IP addresses resolved by the given website name
20+
21+
for (int i = 0;i<in.length;i++){
22+
System.out.println(in[i]+"\t");
23+
}
24+
}
25+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /