java.net.SocketImplFactory Class in Java
Last Updated :
29 Mar, 2023
In Java, SocketImplFactory Class is an interface java.net.SocketImplFactory Class is defining a factory for SocketImpl instances, as this interface is usable by sockets classes to create the sockets execution that implements various policies through it. Interface java.net.SocketImplFactory Class is defining the factory for setting the socketing executions. It uses classes as Socket and ServerSocket to create to its current socket executions on it.
--> java.net Package
--> SocketImplFactory Class
java.net is one of package that use SocketImplFactory in providing the classes for executing on its networking applications.
Method of SocketImplFactory Class
Method |
Action Performed |
createSocketImpl() |
Creating an new SocketImpl instances on it |
Uses of SocketImplFactory Class in java.net package
Method |
Action Performed |
ServerSocket.setSocketFactory(SocketImplFactory fac) |
Setting up an server socketing execution on factories of the application. Using an ServerSocketFactory and its subclass to ServerSocket directly. |
Socket.setSocketImplFactory(SocketImplFactory fac) |
Setting up an client socketing executions factories of its application. Using an SocketFactory and its subclass to Socket directly. |
Example 1:
Java
public void Myserver java_net_SocketImplFactory() {
SecurityManager sm = new SecurityManager() {
public void checkPermission(Permission perm) {
system.out.println(
"message= Hello GFG Readers!" );
}
public void checkSetFactory() {
throw new SecurityException();
}
}
}
|
Output:
Example 2:
Java
public void Myclient java_net_SocketImplFactory() {
SecurityManager obj = new SecurityManager() {
public void checkPermission(Permission perm) {
system.out.println( " " );
}
public void checkSetFactory() {
throw new SecurityException();
}
}
}
|
Output:
Note: In above two code we are only emphasizing on eccentric concept so do not look for the start point of execution of code as main() method is not inserted over here.
Share your thoughts in the comments
Please Login to comment...