Forums / Developer / how to: php socket comunication??

how to: php socket comunication??

Author Message

Alessandro Cipriani

Friday 16 April 2004 2:41:51 am

hi all
that's my problem:
in my pagelayout.tpl i got to make a call to a log server that will register some information i send to it but without opening any browser window.
i read some php documentation and i saw that there is the socket functions that will fit for me.
so i modified the templatestringoperator.php by adding a new function "sendviasocket" in this way:

//send a socket  request
case $this->SendViaSocket:
{
	/* get the port for the WWW service. */
	$service_port = getservbyname('www', 'tcp');
			
	/* get the server address. */
	$address = gethostbyname($namedParameters['address']);

         /*open the socket*/
	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

	$operatorValue=$address;
}break;

no problems until i try to create the socket through the socket_create function
the error is:
Fatal error: Call to undefined function: socket_create() in c:\programmi\ezpublish\ezpublish\lib\eztemplate\classes\eztemplatestringoperator.php on line 192
Fatal error: eZ publish did not finish it's request

should i import (how??) this function in such a way?
is it possible to have a similar behavior?

best regards
alessandro

Bruce Morrison

Sunday 18 April 2004 7:40:39 pm

From the error message it seems that the function "socket_create" is not defined. What version of php are you using? This function was inroduced in 4.1 (see http://au.php.net/manual/en/function.socket-create.php)

Is line 192 the line with the socket_create code ?

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Alessandro Cipriani

Monday 19 April 2004 12:44:24 am

hi bruce!
thanx for your reply, i hope you can help me
yes, the call to the function is in line 192: $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

i'm using ezpublish 3.3-1 with php 4.3.4
what can be the problem? should i import this function in my eztemplatestringoperator.php file?

cheers
alessandro

Bruce Morrison

Monday 19 April 2004 4:06:54 pm

Hi Alessandro

According to http://au.php.net/manual/en/ref.sockets.php -" The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure."

I don't believe that this issue is php related.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Alessandro Cipriani

Tuesday 20 April 2004 12:05:03 am

thanks bruce
there's no way to enable this extension at compile time?
i don't know php (i'm starting learning it now) but i need this feature.
also i think that such a feature will be useful to extend ezpublish, to make it comunicate with other applications.

is there some built-in way to comunicate with other applications by sending them some informations?
Could be ezSoap useful to me?

cheers
alessandro

Alessandro Cipriani

Tuesday 20 April 2004 2:31:31 am

bruce,
is it possible to compile php under windows?
my server is on a windows 2k machine

cheers
alessandro

Bruce Morrison

Tuesday 20 April 2004 2:46:48 am

Don't worry about compiling php under windows - use one of these apache/php/mysql packages :
http://www.firepages.com.au/
http://sourceforge.net/projects/phptriad
http://www.foxserv.net/portal.php

or the many more found at http://www.google.com.au/search?hl=en&ie=UTF-8&oe=UTF-8&q=mysql+php+apache++windows&btnG=Search&meta=

I use linux and cannot vouch for any of them with ezPublish. I have used the first 2 listed in the very distant past.

Cheers
Bruce http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Alessandro Cipriani

Tuesday 20 April 2004 3:19:15 am

hi bruce
thanx for your support
i didn't need to compile anything!!!
i simply "decommented" the line
extension=php_sockets.dll
in my php.ini file
and downloaded the php_sockets.dll (http://kromann.info/php4/php_sockets.dll) and placed it into the winnt/system32 directory

all works perfectly!!

best regards
alessandro

eZ debug

Timing: Jan 31 2025 06:21:30
Script start
Timing: Jan 31 2025 06:21:30
Module start 'content'
Timing: Jan 31 2025 06:21:30
Module end 'content'
Timing: Jan 31 2025 06:21:30
Script end

Main resources:

Total runtime0.2620 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 587.9297180.8359
Module start 'content' 0.00490.0067 768.7656106.0078
Module end 'content' 0.01160.2503 874.7734535.7969
Script end 0.2619  1,410.5703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00321.2264200.0002
Check MTime0.00130.4879200.0001
Mysql Total
Database connection0.00050.207610.0005
Mysqli_queries0.216082.42891410.0015
Looping result0.00120.45941390.0000
Template Total0.249995.410.2499
Template load0.00080.289710.0008
Template processing0.249195.077210.2491
Override
Cache load0.00050.196610.0005
Sytem overhead
Fetch class attribute can translate value0.00060.223310.0006
XML
Image XML parsing0.00030.104910.0003
General
dbfile0.00873.3228200.0004
String conversion0.00000.001830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs