Quick Input -- Sockets vs. HTTP

Discussion in 'Ruby' started by dhtapp, Jan 15, 2004.

  1. dhtapp

    dhtapp Guest

    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
     
    dhtapp, Jan 15, 2004
    #1
    1. Advertising

  2. dhtapp wrote:
    > 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.
     
    Joel VanderWerf, Jan 15, 2004
    #2
    1. Advertising

  3. dhtapp

    dhtapp Guest

    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


    "Joel VanderWerf" <> wrote in message
    news:...
    > dhtapp wrote:
    > > 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.
    >
    >
    >
     
    dhtapp, Jan 16, 2004
    #3
  4. Hi,

    > From: "dhtapp" <>
    > 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
     
    NAKAMURA, Hiroshi, Jan 16, 2004
    #4
  5. dhtapp

    Sam Roberts Guest

    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 , on Fri, Jan 16, 2004 at 11:16:34AM +0900:
    > 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
    >
    >
    > "Joel VanderWerf" <> wrote in message
    > news:...
    > > dhtapp wrote:
    > > > 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.
    > >
    > >
    > >

    >
    >
    >
     
    Sam Roberts, Jan 16, 2004
    #5
  6. "dhtapp" <> schrieb im Newsbeitrag
    news:JtENb.17981$Ar1.3600@fed1read04...
    > 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
     
    Robert Klemme, Jan 16, 2004
    #6
  7. Quoting 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.


    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 , on Fri, Jan 16, 2004 at 11:16:34AM +0900:
    > > 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
    > >
    > >
    > > "Joel VanderWerf" <> wrote in message
    > > news:...
    > > > dhtapp wrote:
    > > > > 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.
    > > >
    > > >
    > > >

    > >
    > >
    > >

    >



    --
    jason

    :wq
    ___________________________________________________________
    This mail sent using ToadMail -- Web based e-mail @ ToadNet
     
    jason r tibbetts, Jan 16, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    474
    Roedy Green
    Jul 28, 2003
  2. BobSmith
    Replies:
    2
    Views:
    621
    BobSmith
    Aug 8, 2005
  3. JKop
    Replies:
    11
    Views:
    894
  4. ed
    Replies:
    14
    Views:
    493
  5. Vasyl Smirnov

    Quick sockets question

    Vasyl Smirnov, Oct 23, 2007, in forum: Ruby
    Replies:
    1
    Views:
    86
    Robert Klemme
    Oct 24, 2007
Loading...

Share This Page