Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > use java.nio for http client?

Reply
Thread Tools

use java.nio for http client?

 
 
Corey_G
Guest
Posts: n/a
 
      05-07-2004
I am writing some code to create an HTTP client. URLConnection (and
HttpURLConnection) seem to be too limited, so I want to do it at the
socket level. It looks like I can choose java.io or java.nio for
doing this. I read nio is newer and "high performance". I am going
to eventually use this as the basis of a load testing tool, so
scalabilty is important.

any advice? is there any reason not to use nio instead of io?

regards,
-Corey Goldberg
 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      05-07-2004
Corey_G wrote:
> I am writing some code to create an HTTP client. URLConnection (and
> HttpURLConnection) seem to be too limited, so I want to do it at the
> socket level. <snip>


Ah, so you want to reinvent the wheel! Good for you!!
One question: how does HttpURLConnection "seem to be too limited"?
Could you give us an all an example of what's missing, enough to
justify designing/developing/debugging code which implements a
standard protocol?
Are you then going to extend it further and write some native code
just so you can REALLY get down to the "nuts and bolts"?
Please do yourself a favour and reconsider.
Very few applications need more than what is already provided. If
you truly believe that your situation is exceptional then please
explain. There just might be a simpler (and standard) mechanism...

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      05-07-2004
On Thu, 06 May 2004 22:45:06 -0400, Sudsy <(E-Mail Removed)>
wrote or quoted :

>
>Ah, so you want to reinvent the wheel! Good for you!!


IT could just be for the learning experience.

It is good for one's soul to write such code, as it writing some sort
of compiler.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      05-07-2004
On Fri, 07 May 2004 04:38:08 GMT, Roedy Green wrote:

> On Thu, 06 May 2004 22:45:06 -0400, Sudsy <(E-Mail Removed)>
> wrote or quoted :

...
>>Ah, so you want to reinvent the wheel! Good for you!!

>
> IT could just be for the learning experience.


The bit at the top of the post you trimmed.. viz.
"I am writing some code to create an HTTP client. URLConnection (and
HttpURLConnection) seem to be too limited, so I want to do it at the
socket level"

Seems to suggest 'No'.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
Tony Morris
Guest
Posts: n/a
 
      05-07-2004
> any advice?
HTTP client using java.nio:
http://java.sun.com/developer/techni.../releases/nio/

> is there any reason not to use nio instead of io?

When supporting VM versions < 1.4

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform


 
Reply With Quote
 
Corey_G
Guest
Posts: n/a
 
      05-07-2004
> Ah, so you want to reinvent the wheel! Good for you!!
> One question: how does HttpURLConnection "seem to be too limited"?
> Could you give us an all an example of what's missing, enough to
> justify designing/developing/debugging code which implements a
> standard protocol?


Thanks for the positive and encouraging response!

My question wasn't "should I write my own http client?" My question
was "I AM GOING TO write my own http client, what should I use". I am
new to java, but have written socket level clients in many other
languages. So part of the purpose is a learning experience in how to
write java.. part of the purpose is to learn network and socket
programming in java.

> Please do yourself a favour and reconsider.


reconsider what? learning socket programming in java by plugging in
some pre-baked code thats already written? If this was small piece of
larger client project, I would most likely use something like the
Jakarta Commons HttpClient.
But its rather difficult to learn socket programming without actually
doing socket programming.. don't you think?

thanks again for your support.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      05-07-2004
On 7 May 2004 05:59:29 -0700, Corey_G wrote:

> My question wasn't "should I write my own http client?" My question
> was "I AM GOING TO write my own http client, what should I use".


OoooK..

>...I am
> new to java, but have written socket level clients in many other
> languages. So part of the purpose is a learning experience in how to
> write java.. part of the purpose is to learn network and socket
> programming in java.


So _this_ is the bit Sudsy was supposed to see in
his Crystal Ball? I got it.

Problem is, the only 'crystal' Sudsy's got is
better suited to the containmnent a far more
important thing, beer.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
electric sheep
Guest
Posts: n/a
 
      05-07-2004
Sudsy <(E-Mail Removed)> wrote:
> Corey_G wrote:
>> I am writing some code to create an HTTP client. URLConnection (and
>> HttpURLConnection) seem to be too limited, so I want to do it at the
>> socket level. <snip>

>
> Ah, so you want to reinvent the wheel! Good for you!!
> One question: how does HttpURLConnection "seem to be too limited"?
> Could you give us an all an example of what's missing, enough to
> justify designing/developing/debugging code which implements a
> standard protocol?
> Are you then going to extend it further and write some native code
> just so you can REALLY get down to the "nuts and bolts"?
> Please do yourself a favour and reconsider.
> Very few applications need more than what is already provided. If
> you truly believe that your situation is exceptional then please
> explain. There just might be a simpler (and standard) mechanism...


I'm sure this is unrelated to why he thinks it is too limited,
but I too was thinking of doing my own "HttpURLConnection" class for
this reason:

There is no way to set a reasonable time out value for the connection.

I am interested in writing 2 apps. A website mirroring tool, and a proxy
checker. Each of which will fire up several threads. Most good website
mirroring tools allow the user to specify the timeout period, and I was
thinking of doing the same.

Any ideas ?
 
Reply With Quote
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      05-07-2004
electric sheep wrote:


> I'm sure this is unrelated to why he thinks it is too limited,
> but I too was thinking of doing my own "HttpURLConnection" class for
> this reason:
>
> There is no way to set a reasonable time out value for the connection.
>
> I am interested in writing 2 apps. A website mirroring tool, and a proxy
> checker. Each of which will fire up several threads. Most good website
> mirroring tools allow the user to specify the timeout period, and I was
> thinking of doing the same.
>
> Any ideas ?


Jakarta commons HttpClient allows you to specifiy the timeouts.

--
Kind regards,
Christophe Vanfleteren
 
Reply With Quote
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      05-07-2004
Corey_G wrote:
> My question wasn't "should I write my own http client?" My question
> was "I AM GOING TO write my own http client, what should I use".


And you got your answer: URLConnection.

> I am
> new to java,


So this gives you enough competence to tell us all that URLConnection is
to limited for your purpose? For the purpose which you refused to state
until now? Oh no, wait, you originally wrote:

>>> I am going
>>> to eventually use this as the basis of a load testing tool, so
>>> scalabilty is important.


But now you say

> So part of the purpose is a learning experience


And why didn't you tell us this the first time? People here usually
don't program for the learning experience, but to solve real world
problems. Consider to have your learning experience in
comp.lang.java.help instead.

> in how to
> write java.


And you got your answer: Use the pre-existing classes on the highest
possible abstraction layer. This is how things are done in Java.

> reconsider what?


Your attitude. Your way of formulating questions. Your way of handling
the good advice you got. Your bad case of "not invented here" syndrome.

> learning socket programming in java by plugging in
> some pre-baked code thats already written?


Nowhere in your original post you mentioned that you want to learn Java
socket programming. Don't blame us for your inability to express your
wishes.

/Thomas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm ASP .Net 2 09-07-2010 07:37 AM
Split Tunnel Blocks http through tunnel but passes http around tunnel a.nonny mouse Cisco 2 09-19-2004 12:10 AM
Getting "HTTP Error 403 - Forbidden" at http://localhost/quickstart/ASPPlus/ Scott MCSD 1 08-04-2004 05:28 PM
HttpModule -- how to intercept urls like http://localhost/abc/def or http://localhost/abc/def/ where abc, def are non virtual dir Jiong Feng ASP .Net 0 11-19-2003 05:29 AM



Advertisments