Quick Input -- Sockets vs. HTTP

D

dhtapp

Hi,

I'm fiddling with a little personal client/server project (still in the
"toy" stage), mainly to get somewhat better at a few different things
simultaneously.

The first draft of the server is going to be Ruby 1.8, using a pstore for
backing. The first shot at the client is in Java 1.4, using Eclipse and SWT
(which I'm also learning).

I'm at the point where I need to settle on a communication strategy. (As a
WebObjects techie for the past few years, this kind of stuff all happened
automagically for me.) Looking through the Pickaxe book and some of the
whitepapers up on java.sun.com, I find myself wondering whether HTTP or
socket-level would be a better payoff, ultimately.

For now, the communications can be XML-ish plaintext, i.e.

-- From client
<login_request>
<username>dan</username>
<password>fido</password>
</login_request>

-- From server
<login_response>
<status>OK</status>
<session_key>1aBwhateverfoo</session_key>
</login_response>

But I also find myself wondering if it wouldn't be possible to occasionally
pass Java objects across the wire and have them stored in the Ruby pstore
(using, I guess, some magic with Array#pack...?)

So, to anyone with more network programming experience in both Ruby and
Java, my question is: if you were in my position, which approach would you
take? Or, maybe more appropriately, what kinds of questions should I be
asking myself to help make the determination?

Thanks!

-- dan
 
J

Joel VanderWerf

dhtapp said:
So, to anyone with more network programming experience in both Ruby and
Java, my question is: if you were in my position, which approach would you
take? Or, maybe more appropriately, what kinds of questions should I be
asking myself to help make the determination?

What about XML-RPC? That's in the ruby stdlib as of 1.8.0.
 
D

dhtapp

Hi,

Thanks for the thought. I'm keeping that on the back burner for now. I'd
prefer to pass data only at this stage, without invoking anything
directly...

- dan
 
N

NAKAMURA, Hiroshi

Hi,
From: "dhtapp" <[email protected]>
Newsgroups: comp.lang.ruby
Sent: Friday, January 16, 2004 7:31 AM
But I also find myself wondering if it wouldn't be possible to occasionally
pass Java objects across the wire and have them stored in the Ruby pstore
(using, I guess, some magic with Array#pack...?)

So, to anyone with more network programming experience in both Ruby and
Java, my question is: if you were in my position, which approach would you
take? Or, maybe more appropriately, what kinds of questions should I be
asking myself to help make the determination?

* Security requirements
* App level authentication needed?
* Are there 3 or more participants in the security domain?

* Transaction
* Need 2-phase commit? Oh, ignore this. I just want to say. :)
* 2 or more communication can be organized?
* Error status transfer?
* Required reliability?
* Bulk data transfer (independent 2 or 3 msgs at once) needed?

* Data type
* Includes binary data?
* Data complexity?
* Extensibility?
* Required language binding? Only Ruby/Java?

And extensibility in the future. You might not have to think about
it (YAGNI).

For example, I choose followings for my company projects;

* CORBA between C++/Java
* CSV over HTTP between C++/PSQL
* XML over HTTPS between C++/(I don't know)
* SOAP over COM between JScript/C++
* XML over e-mail between Java/(I don't know)
* SOAP over HTTPS between Ruby/Perl/Java

Regards,
// NaHi
 
S

Sam Roberts

I don't know about Ruby's XML-RPC implementation, but there is nothing
about xml-rpc which would force you to do any kind of "invocation",
though I'm not to sure what you mean. The XML you posted looks very much
like what xml-rpc marshals calls and returns into, you could probably
just use the marshalling code.

Sam

Quoteing (e-mail address removed), on Fri, Jan 16, 2004 at 11:16:34AM +0900:
 
R

Robert Klemme

dhtapp said:
Hi,

I'm fiddling with a little personal client/server project (still in the
"toy" stage), mainly to get somewhat better at a few different things
simultaneously.

The first draft of the server is going to be Ruby 1.8, using a pstore for
backing. The first shot at the client is in Java 1.4, using Eclipse and SWT
(which I'm also learning).

I'm at the point where I need to settle on a communication strategy. (As a
WebObjects techie for the past few years, this kind of stuff all happened
automagically for me.) Looking through the Pickaxe book and some of the
whitepapers up on java.sun.com, I find myself wondering whether HTTP or
socket-level would be a better payoff, ultimately.

For now, the communications can be XML-ish plaintext, i.e.

-- From client
<login_request>
<username>dan</username>
<password>fido</password>
</login_request>

-- From server
<login_response>
<status>OK</status>
<session_key>1aBwhateverfoo</session_key>
</login_response>

But I also find myself wondering if it wouldn't be possible to occasionally
pass Java objects across the wire and have them stored in the Ruby pstore
(using, I guess, some magic with Array#pack...?)

I don't think that array pack is appropriate. But you can use XMLEncoder
and XMLDecoder to serialize a bean to / from XML:
http://java.sun.com/j2se/1.4.2/docs/api/java/beans/XMLEncoder.html

Maybe you can invent a Ruby class that reads this XML and builds an object
graph from that. Of course you'd have to do some translations of method
names etc. But I don't think it is far fetched.
So, to anyone with more network programming experience in both Ruby and
Java, my question is: if you were in my position, which approach would you
take? Or, maybe more appropriately, what kinds of questions should I be
asking myself to help make the determination?

I think HTTP is a good starting point if that protocol suits your
application (i.e. only message exchange, no permanent connection) because
there are tools for that on both sides. If encapsulated properly you can
exchange it later if you feel the need. If you choose sockets, you'll
have to implement yourself what lots of others have done already: network
communication protocols. While HTTP is a bit limited, there are CORBA,
RMI, XML-RPC, SOAP via HTTP etc.

Regards

robert
 
J

jason r tibbetts

Quoting Sam Roberts said:
I don't know about Ruby's XML-RPC implementation, but there is nothing
about xml-rpc which would force you to do any kind of "invocation",
though I'm not to sure what you mean. The XML you posted looks very much
like what xml-rpc marshals calls and returns into, you could probably
just use the marshalling code.

I second the suggestion of XML-RPC. Ruby's XML-RPC library (the standalone
version--is it the same as the one in 1.8?) is quite elegant. In fact, I've just
been writing an XML-RPC app in Java, and when I wrote a toy client in Ruby to
access it, I sorely wished that I could have scrapped the Java one and used Ruby
exclusively. But there are clients' needs that have to be taken into
consideration. :(

But back to your original question--socket-level communication may be cheaper
and faster (execution-wise), but a little more trouble to maintain. HTTP,
however, is easy.
Quoteing (e-mail address removed), on Fri, Jan 16, 2004 at 11:16:34AM +0900:


--
jason

:wq
___________________________________________________________
This mail sent using ToadMail -- Web based e-mail @ ToadNet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top