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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 04:42:24
Script start
Timing: Jan 19 2025 04:42:24
Module start 'layout'
Timing: Jan 19 2025 04:42:24
Module start 'content'
Timing: Jan 19 2025 04:42:24
Module end 'content'
Timing: Jan 19 2025 04:42:24
Script end

Main resources:

Total runtime0.8109 sec
Peak memory usage4,096.0000 KB
Database Queries72

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 589.1563152.6250
Module start 'layout' 0.00790.0035 741.781339.4453
Module start 'content' 0.01140.7981 781.2266621.4688
Module end 'content' 0.80950.0014 1,402.695320.1563
Script end 0.8109  1,422.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4119160.0002
Check MTime0.00130.1559160.0001
Mysql Total
Database connection0.00150.186110.0015
Mysqli_queries0.724489.3270720.0101
Looping result0.00070.0854700.0000
Template Total0.781196.320.3905
Template load0.00240.297720.0012
Template processing0.778796.021820.3893
Template load and register function0.00010.016410.0001
states
state_id_array0.00080.096310.0008
state_identifier_array0.00100.124320.0005
Override
Cache load0.00230.2791790.0000
Sytem overhead
Fetch class attribute can translate value0.00090.114220.0005
Fetch class attribute name0.00130.1654100.0001
XML
Image XML parsing0.00110.140920.0006
class_abstraction
Instantiating content class attribute0.00000.0050160.0000
General
dbfile0.00110.1326220.0000
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
18content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 57
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs