Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 322 Vote(s) - 3.39 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java Networking

#1
[shadow=black]JAVA NETWORKING TUTORIAL[/shadow]
[shadow=green]Imports Needed:[/shadow]
  • Java.io.*
  • Java.util.*
  • Java.net.*

[shadow=red]Objects Used:[/shadow]
  • 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


[shadow=blue]Examples/explenations of all:[/shadow]



InetAddress:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


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 || www.google.com" would print out.

Inet4Address:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


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 substitute "localhost" with "www.google.com" the output will end up as "IP address is: 173.194.46.20"

Inet6Address:



Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code would print out the IPv6 address of any given host. For example, if you replace ADDRESS_AS_STRING_GOES_HERE with a host that has an IPv6 address, it would print out said IPv6 address. However, due to the fact that I don't know of any IPv6 address using sites/hosts, I can not show you example output.


SocketAddress:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code will set up a new connection to a given host on a given port. For example, if HOST_AS_STRING was replaced with "www.google.com" and PORT_AS_INT was replaced with 80, a new connection would be set up(accessible)(connections are made with a socket) with google on port 80 (www.google.com:80).


Socket:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code will make a connection to any given host/port. For example, if HOST_AS_STRING was replaced with "www.google.com" and PORT_AS_INT was replaced with 80 a new connection would be made with google on port 80 (www.google.com:80) and "Connection made" would be printed to the screen.

ServerSocket:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code will accept all incoming connections from clients to that ip address. Thus, if we use a Socket and change the IP to the IP of the server, the server will willingly accept the connection.


DatagramPacket:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code will make a UDP packet with the size of 65508 and set it up so that when it is sent it will go straight to the given host on the given port. For example, If we changed ADDRESS_AS_STRING to "www.google.com" and PORT_AS_INT to 80, we would have made a large packet set up to send to google on port 80 (not sent until we send it with DatagramSocket).


DatagramSocket:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code will send a udp packet with the given message on it, to the given host on the given port. For example, if we changes MESSAGE_AS_STRING to "Hello Java Networking!" and ADDRESS_AS_STRING to "www.google.com" and PORT_AS_INT to 80, we would have sent a UDP packet with the message "Hello Java Networking!" to google on port 80 (www.google.com:80)




[shadow=black]I HOPE THIS TUTORIAL HELPED YOU! KEEP AN EYE OUT FOR MY OTHER NETWORKING TUTORIALS FOR DIFFERENT LANGUAGES![/shadow]
Reply

#2
Damn. HQ. Good job.
Reply

#3
Quote:(02-01-2013, 05:21 AM)Zealotry Wrote:

[To see links please register here]

Damn. HQ. Good job. :biggrin:

thanks, I'll be making another one for python soon.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through