Home » Core Java » net » Page 4

net

Get IP address and hostname from local machine

Bipartite Graph

In this example we shall show you how to retrieve the IP address and hostname from the local host. To get the IP address and hostname from the local machine one should perform the following steps : Retrieve the Address object for the local host. This object contains all address related information about the specific host Use the getAddress() API ...

Read More »

Get IP address from hostname

Bipartite Graph

In this example we shall show you how to retrieve the IP address from the hostname of a specific host. To get the IP address using a hostname one should perform the following steps : Retrieve the Address object of the specific host. This object contains all address related information about the specific host Use the getAddress() API method to ...

Read More »

Send network DatagramPacket

Bipartite Graph

This is an example of how to send a Datagram packet over the network in Java. Sending Datagram packets between two hosts in Java implies that you should : Retrieve the Address object of the target host. This object contains all address related information about the specific host Create a DatagramPacket Object providing the actual data to be send, the ...

Read More »

Receive network DatagramPacket

Bipartite Graph

In this example we shall show you how to receive a Datagram packet in Java. For a host to receive Datagram packets in Java implies that you should : Create a DatagramPacket Object providing a placeholder for the received data – here an empty byte array of the default 256 bytes size Create a DatagramSocket Object to receive the Datagram ...

Read More »

Get response headers from HTTP request

Bipartite Graph

With this example we are going to demonstrate how to get response headers from an HTTP request in Java. In short, to get the response headers from an HTTP request you should : Create a URL Object that represents the resource you want to access Use the openConnection() API method of the URL Object to access connection specific parameters for ...

Read More »

Send cookie with HTTP request

Bipartite Graph

This is an example of how to send a cookie with an HTTP request in Java. In short, to send cookies with HTTP requests one should : Create a URL Object that represents the resource you want to access Use the openConnection() API method of the URL Object to access connection specific parameters for the HTTP request Use the setRequestProperty() ...

Read More »

Get cookies from HTTP connection

Bipartite Graph

With this example we are going to demonstrate how to get cookies from an HTTP connection in Java. In short, to retrieve cookie information of a URL connection you should Create a URL Object that represents the resource you want to access Use the openConnection() API method of the URL Object to access connection specific parameters for the HTTP request ...

Read More »