Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use SocketImplFactory to manipulate sockets in whole application?

Ilya Kalujny
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I need your kind advice here.

What I need is basically for every socket in my application ( that doesnt deal directly with Sockets ) to have TCP_NODELAY set to true.

I consulted JDK javadocs regarding static Socket.setSocketImplFactory(...) method and interface in hopes of implementing it to create some standard SocketImpl`s for me and calling .setOption( , ... ) on them, but there seems not to be any publicly available SocketImpl implementations for that. Closest is, but I obviously cant subclass that since it has default access in the package. I read somewhere that reflection could be used to subclass a class with default access, but I`d rather not get into that mess.

Another interesting class is, that I could subclass, override abstract methods by calling super and setting desired option with .setTcpNoDelay(true) on created sockets, but I failed to find any way to set my subclass into the system so it gets used instead of the default one.

I`m at a loss. Could anyone please provide any insight?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic