[Freeswitch-users] ESL, phpmod

Helmut Kuper helmut.kuper at ewetel.de
Fri Jun 18 08:42:33 PDT 2010


Hello,

I found a solution which seems to works for me so far. At least I can
use esl-phpmod now.

Problem is, that php's socket_accept() functions returns a resource
instead of a file descriptor. So esl-phpmod has to find out the
corresponding file descriptor before "new ESLconnection()" is called.

Here my svn diff for the FS ESL developer to get it reviewed:

Index: php/esl_wrap.cpp
===================================================================
--- php/esl_wrap.cpp    (Revision 17782)
+++ php/esl_wrap.cpp    (Arbeitskopie)
@@ -1793,7 +1793,7 @@


 ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) {
-  int arg1 ;
+  int arg1, type, *p;
   ESLconnection *result = 0 ;
   zval **args[1];

@@ -1806,6 +1806,12 @@
   /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/
   convert_to_long_ex(args[0]);
   arg1 = (int) Z_LVAL_PP(args[0]);
+  //Find the needed numeric file descriptor
+  //First get the Resource object
+  p=(int*)zend_list_find(arg1, &type);
+  if (!p) goto fail;
+  //Second, get the file descriptor
+  arg1 = *p;
   /*@SWIG@*/;

   result = (ESLconnection *)new ESLconnection(arg1);
@@ -1825,9 +1831,7 @@
   argc = ZEND_NUM_ARGS();
   zend_get_parameters_array_ex(argc,argv);
   if (argc == 1) {
-    int _v;
-    _v = (Z_TYPE_PP(argv[0]) == IS_LONG);
-    if (_v) {
+    if (Z_TYPE_PP(argv[0]) == IS_RESOURCE) {
       return
_wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU);
     }
   }



regards
Helmut


On 17.06.2010 09:55, Helmut Kuper wrote:
> Hi,
> 
> a bit success now. When I use this command:
> 
> $con = new ESLconnection(intval($csock));
> 
> I got an ESLconnection object, but it is not usable. var_dump($con) shows
> 
> object(ESLconnection)#1 (1) {
>   ["_cPtr"]=>
>   resource(7) of type (_p_ESLconnection)
> }
> 
> 
> which looks good to me, but strace still shows "Bad file descriptor":
> 
> setsockopt(6, SOL_TCP, TCP_NODELAY, [1], 4) = -1 EBADF (Bad file descriptor)
> sendto(6, "connect\n\n", 9, 0, NULL, 0) = -1 EBADF (Bad file descriptor)
> 
> Calling $con->getINFO() results in NULL ...
> 
> 
> regards
> Helmut
> 
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
> 
> 



More information about the FreeSWITCH-users mailing list