Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raw socket in java [closed]

I am pretty new to java socket programming. I had already gone thorugh that java only deals with Internet Domain Sockets and it will support UDP and TCP and Raw IP Protocols. I want to know that is java support Raw Sockets without using any third party applications? If it is possible can anyone help me with a small example? Any small advice will be very greatful!

like image 821
Nikhil Avatar asked Feb 14 '13 10:02

Nikhil


People also ask

What does socket close () do?

close() call shuts down the socket associated with the socket descriptor socket, and frees resources allocated to the socket. If socket refers to an open TCP connection, the connection is closed. If a stream socket is closed when there is input data queued, the TCP connection is reset rather than being cleanly closed.

How do I know if my client socket is closed?

isClosed() tells you whether you have closed this socket. Until you have, it returns false.

Should you close a socket Java?

The finalize() method is called by the Java virtual machine ( JVM ) before the program exits to give the program a chance to clean up and release resources. Multi-threaded programs should close all Files and Sockets they use before exiting so they do not face resource starvation.

What are raw socket privileges?

A raw socket is a type of socket that allows access to the underlying transport provider. This topic focuses only on raw sockets and the IPv4 and IPv6 protocols. This is because most other protocols with the exception of ATM do not support raw sockets.


1 Answers

The only really available support for raw sockets in Java standard library seems the InetAddress.isReachable() that may do ICMP ping if permitted. This is really not much and probably even not really a raw socket, just one more protocol.

For other types of raw communication I would recommend to use Berkley sockets under Linux (root rights required) through some JNI - based wrapper.

like image 60
Audrius Meškauskas Avatar answered Oct 03 '22 11:10

Audrius Meškauskas