Socket setSocketImplFactory Example

Started by VelMurugan, Jan 02, 2009, 07:10 AM

Previous topic - Next topic

VelMurugan

Socket setSocketImplFactory Example

Socket class setSocketImplFactory example. This example shows you how to use setSocketImplFactory method.

Socket class setSocketImplFactory example. public static void setSocketImplFactory(SocketImplFactory fac) throws IOException Sets the client socket implementation factory for the application. The factory can be specified only once.

Here is the code

/*
* @ # SetSocketImplFactory.java
* A class repersenting use to SetSocketImplFactory method
* of NumberFormat class in java.net package
* version 17 June 2008
* author Rose India
*/

import java.net.*;

public class SetSocketImplFactory {

    public static void main(String args[]) throws Exception {
        Socket socket = new Socket();

        //Connects this socket to the server.
        socket.connect(new InetSocketAddress("192.168.10.222", 8080));
       
        Socket.setSocketImplFactory(new SocketImplFactory() {

            public SocketImpl createSocketImpl() {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
        System.out.println("Unsupported Operation Exception not come...");
        socket.close();
    }
}


Output
Unsupported Operation Exception not come...

Source : codingdiary