Communication with php fastcgi socket from ruby -


i wish check correct php fastcgi operation ruby script. do that, wanted send simple php script socket , check correct return value.

now, new both ruby , sockets, tried

require 'socket'  s = unixsocket.new("/var/run/php/php.socket") s.send('<?php print "hello world"; ?>', 0) puts s.recv(11) 

but

test.rb:5:in `recv': connection reset peer - recvfrom(2) (errno::econnreset)           test.rb:5:in `<main>' 

google less helpful, because 'php' triggers many tutorials on how use sockets php.

i know php socket works correctly (since powers website). how script correctly receive "hello world"?

fastcgi has binary protocol need implement. in end you'd better use library has implemented you.

after might better off using bash script , program installed libfcgi library (apt-get install libfcgi-dev on debian), example

script_filename=/path/test.php cgi-fcgi -bind -connect /var/run/php/php.socket 

(jens corrected original example environment in comment, thanks)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -