1

I am currently working on a small Networking - Library and trying to unite a few socket related classes like e.g. Socket, SocketChannel, DatagramSocket, DatagramSocketChannel, so that the user is able to implement his own Sockets really simple.

The implementation of an own socket should be done by just inheriting from a super - class giving some methods to implement. Thus the methods implemented are ready to be passed on to a class, that inherits the e.g. SocketImpl - Class. The implemented methods will be put into the corresponding methods of the SocketImpl subclass, so that a final call to the Socket.setSocketImplFactory function would finish off the whole procedure.

But this only works for the Socket and DatagramSocket classes because of them having the static methods Socket.setSocketImplFactory and DatagramSocket.setDatagramSocketImplFactory.

Now I have seen that the NIO Sockets like SocketChannel and DatagramSocketChannel have a method socket() that returns either a Socket or a DatagramSocket.

So my final questions after the long journey are: In how far would a call to the Socket.setSocketImplFactory, given a custom SocketImplFactory, affect the Socket returned by the SocketChannel::socket method? Is it possible to customize a SocketChannel by just "manipulating" the Socket returned by the socket() method?

Chip
  • 11
  • 3

0 Answers0