Preview

java networking

Satisfactory Essays
Open Document
Open Document
792 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
java networking
The Basics of Java Networking by Daniel Bloom

JAVA NETWORKING TUTORIAL

Imports Needed:

Java.io.*
Java.util.*
Java.net.*

Objects Used:

InetAddress - creates an IP connection to a specified host
Inet4Address - Creates an IPv4 connection to a specified host
Inet6Address - Creates an IPv6 connection to a specified host
SocketAddress - provides an immutable object used by sockets for binding, connecting, or as returned values. (Abstract class (used with InetAddress))
Socket - Opens a TCP socket to a specific IP address
ServerSocket - Creates a server for Sockets to connect to (Only needed for client/server networing)
DatagramPacket - Creates a UDP packet which connects through the DatagramSocket
DatagramSocket - creates a UDP socket to send DatagramPackets

Examples/explenations of all:

InetAddress:

public static void inetmethod() throws UnknownHostException{
InetAddress address =InetAddress.getByName(ADDRESS_AS_STRING_GOES_HERE);
System.out.println(address.getHostAddress() +" || "+ address.getHostName()); }

The above doe will print out the IP address of anything given and it's host name. For example, if ADDRESS_AS_STRING_GOES_HERE was substituted with "www.google.com" then "173.194.46.20 || http://www.google.com" would print out.

Inet4Address:

import java.net.*; import java.util.*;

public class GetAddress {

public static void main(String[] args) throws Exception { String result = ""; InetAddress i = Inet4Address.getByName("localhost"); //returns the raw IP address of object. byte b[] = i.getAddress(); System.out.print("IP address is: "); for (int j = 0; j < b.length; j++) { result+= b[j]; result+= "."; } System.out.print(result); }
}

The above code will print out the IPv4 address of any given host. For example, the above code, will print out "IP address is: 127.0.0.1". However, if we

You May Also Find These Documents Helpful

  • Satisfactory Essays

    6. To what IP address is the DNS query message sent? Use ipconfig to determine the…

    • 671 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    Specifies the DNS domain name that the client should use for DNS computer name resolution.…

    • 1103 Words
    • 4 Pages
    Better Essays
  • Satisfactory Essays

    NT1210 LAb6.1

    • 401 Words
    • 2 Pages

    The IP config show you everything you need to know from your IP address and your gateway and basically it shows you your networking.…

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Nt1330 Unit 3 Assignment 1

    • 2019 Words
    • 9 Pages

    10001100.10110011.11011100.11001000 We see the address in the decimal form Your computer sees it in the binary form Binary Octet: • An octet is made up of eight “1”s and “0”s, representing the following values: 128 64 32 16 8 4 2 1 • So the value of 140 (the first octet of our example) looks like this: 1 0 0 0 1 1 0 0 Binary Octet: 1 0 128…

    • 2019 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    Nt1310 Unit 7

    • 458 Words
    • 2 Pages

    Identify the three IP address classes, the default subnet mask used with each, and the number of hosts for each.…

    • 458 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    192.168.1.1, this may seem like an ordinary IP address. However it is not so ordinary. This is the IP address used by several network brands like Linksys and others as an access point. This IP serves as a WLAN to route the requests of sevreal routers. The routers’ admin access needs to be configured on this IP address. By doing this configuration firms allow the network administrators to configure the networks and routers owned by them. This IP is used for several purposes which include – managing security options, IP QoS, DSL, ADSL, Network management, DNS, LAN, WAN, proxy, WLAN settings, MAC, WPS block and several other options.…

    • 570 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    2640 U3 A1

    • 292 Words
    • 2 Pages

    For a network address, what does the host portion of the address appear as in binary representation?…

    • 292 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    NT1330 final exam

    • 1081 Words
    • 3 Pages

    16. Which enables a host to determine another host’s name based on its IP address? Reverse look-up zone…

    • 1081 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Comp230 Week 1 Lab Report

    • 941 Words
    • 4 Pages

    Copy and paste the specified ipconfig /all command output from the Windows CLI into the Task 1 box provided below.…

    • 941 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Unit 3 Lab

    • 290 Words
    • 2 Pages

    DNS converts common domain names into IP addresses to route data to the correct destination over the internet without having the user provide the exact IP address.…

    • 290 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    NT1330 FINAL EXAM NOTES

    • 1446 Words
    • 5 Pages

    IPv4 addresses are commonly represented using what is called dotted-decimal notation, in which the decimal value of each byte is shown, using periods to separate the bytes.…

    • 1446 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Unit 8 Assignment 1

    • 349 Words
    • 1 Page

    IP address: A 32-bit binary number, often written in the DDN format, that hosts use as their unique identifier in a TCP/IP network, much like a postal mailing address in the postal system.…

    • 349 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    IPv4 has different class types: A,B,C,D and E. Class A, Class B, and Class C are the three classes of addresses used on IP networks in common practice. Class D addresses are reserved for multicast. Class E addresses are simply reserved, meaning they should not be used on IP networks (used on a limited basis by some research organizations for experimental purposes). IPv4 has different class types: A,B,C,D and E. Class A, Class B, and Class C…

    • 981 Words
    • 4 Pages
    Powerful Essays
  • Satisfactory Essays

    Chapter 13 Quiz

    • 256 Words
    • 2 Pages

    A reverse lookup allows you to specify an IP address and the DNS server returns the host name that is defined for it.…

    • 256 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    NT1210 Final Exam Review

    • 726 Words
    • 3 Pages

    Truth Table 0 AND 0 = False (0) / 1 AND 0 False (0) / 1 AND 1 True (1)…

    • 726 Words
    • 3 Pages
    Satisfactory Essays