This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

is any one using pure sockets

 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or if they are migrating to 3rd party packages that are built on top of socket programming??
 
author
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really depends completely on what the developer is writing. For instance, if your program's only interaction with network servers is talking to a SQL database, then you'd have to be crazy to use low-level socket code instead of JDBC or something even higher level like Hibernate. If the high-level frameworks do what you need, great! By all means use them.

However, frameworks are never going to do everything. There will always be new protocols and network services that have to be implemented with low-level socket code before a framework can be layered on top of them. Someone has to write the frameworks, after all. But more importantly, the frameworks tend to be quite focused on the server side. People writing clients have much less sophisticated libraries to help them; and they do often need to use sockets or the URL/URLConnection/protocol handler framework built into Java.
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming to urlconnection approach, do you have any suggestion for a reliable timeout supported HttpUrlConnection kind of package.

Thanks for your input.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure there is still no way to do a timeout on URLConnection.

In Java 1.5, you can set a System property (which specifies a system wide timeout for the entire JVM -- not a good idea from inside an application server and may not even be allowed by the Security Manager).

The best solution that I have found is to use HttpClient from Jakarta
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Apache HTTP Client package has an HttpUrlConnection equivalent with timeout. I really need to read it and see how they did it one day.

A neat approach is to open the connection then pass it to another thread that waits a while and closes it. That causes the first thread to throw an exception. I needed something like this, but I'm running inside EJB and can't manage my own threads. Rats.

I spent a day playing with writing my own HttpUrlConnection-like class that had a raw socket with socket timeout. I only needed a small subset of the methods, but implementing HTTP is a non-trivial task.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!