[Chicago-talk] Sockets & Hashes

Jason Rexilius jason at hostedlabs.com
Sun Mar 25 21:09:01 PDT 2007

serialize... unserialize.. two calls, one on either end, deal with 
native hash structures.. thats with RAW sockets.

LWP or Mechanize, same diff.

The exact question is what is at the other end of the socket?  Perl 
daemon, perl CGI, C daemon, etc..?

If you are talking perl-to-perl over TCP socket and just want to pass 
data structures back and forth, serialize/unserialize will probably be 
the simplest.

If you need some extra error handling, auth, SSL, et al. use one of the 
afore mentioned modules. (there are a few dozen others as well as the 2 
we mentioned).

Do you have a nice stable mature listener on the other end (i.e. apache, 
postifx, etc.) or are you rolling your own daemon.. is synchronisity 
required or can you drop things on a queue, .. blah blah blah..

Some more info helps us verbose people offer more exact advice..

Jonathan Rockway wrote:
> On Sunday 25 March 2007 18:22, Jason Rexilius wrote:
>> You could serialize it and then send it over a raw TCP socket, yes.
>> Or you could use a higher level protocol like XML-RPC or HTTP.. HTTP
>> Mechanize on one side and CGI on the other is probably the most mature
>> as far as built-in error handling and stuff, most code for cop-paste
>> re-use etc..
> That alone doesn't do anything, you need to convert the hash to something that 
> the other side can convert back to a hash.  Most people use JSON, YAML, or 
> XML for this.
> Also, you want LWP::UserAgent, not Mechanize in this case (although Mech is a 
> subclass of LWP::UA...).  You don't need to "browse" the remote site if 
> you're just an API client.  For example, just send an HTTP::Request 
> containing your request in JSON and read the HTTP::Response containing the 
> answer, encoded in JSON.  See:
> ------------------------------------------------------------------------
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk

More information about the Chicago-talk mailing list