That's unacceptable. you cannot patch a generated swig file.<div><br></div><div>you need to learn what function in php gives you the raw file descriptor number from your socket and pass that to the constructor as required.</div>
<div><br></div><div>The whole time your problem is that you don't know how to do this in PHP so you should stop looking in the code and just find the php method of a socket object to product the real file descriptor.</div>
<div><br></div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">On Fri, Jun 18, 2010 at 11:36 AM, Samuel Macedo <span dir="ltr"><<a href="mailto:macedoslm@gmail.com">macedoslm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Helmut,<div><br></div><div>I've applied the patch and it's working well. Thanks for your help.</div><div><br></div>
<div>Regards,</div><div>--</div><div>Samuel Macedo<div><div></div><div class="h5"><br><br><div class="gmail_quote">On 18 June 2010 13:07, Samuel Macedo <span dir="ltr"><<a href="mailto:macedoslm@gmail.com" target="_blank">macedoslm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Helmut,<div><br></div><div>Thanks for the patch. I'll try it.</div><div><br></div><div>Regards,</div><div>--</div>
<div>Samuel Macedo<div><div></div><div><br><br><div class="gmail_quote">On 18 June 2010 12:42, Helmut Kuper <span dir="ltr"><<a href="mailto:helmut.kuper@ewetel.de" target="_blank">helmut.kuper@ewetel.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I found a solution which seems to works for me so far. At least I can<br>
use esl-phpmod now.<br>
<br>
Problem is, that php's socket_accept() functions returns a resource<br>
instead of a file descriptor. So esl-phpmod has to find out the<br>
corresponding file descriptor before "new ESLconnection()" is called.<br>
<br>
Here my svn diff for the FS ESL developer to get it reviewed:<br>
<br>
Index: php/esl_wrap.cpp<br>
===================================================================<br>
--- php/esl_wrap.cpp (Revision 17782)<br>
+++ php/esl_wrap.cpp (Arbeitskopie)<br>
@@ -1793,7 +1793,7 @@<br>
<br>
<br>
ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) {<br>
- int arg1 ;<br>
+ int arg1, type, *p;<br>
ESLconnection *result = 0 ;<br>
zval **args[1];<br>
<br>
@@ -1806,6 +1806,12 @@<br>
/*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/<br>
convert_to_long_ex(args[0]);<br>
arg1 = (int) Z_LVAL_PP(args[0]);<br>
+ //Find the needed numeric file descriptor<br>
+ //First get the Resource object<br>
+ p=(int*)zend_list_find(arg1, &type);<br>
+ if (!p) goto fail;<br>
+ //Second, get the file descriptor<br>
+ arg1 = *p;<br>
/*@SWIG@*/;<br>
<br>
result = (ESLconnection *)new ESLconnection(arg1);<br>
@@ -1825,9 +1831,7 @@<br>
argc = ZEND_NUM_ARGS();<br>
zend_get_parameters_array_ex(argc,argv);<br>
if (argc == 1) {<br>
- int _v;<br>
- _v = (Z_TYPE_PP(argv[0]) == IS_LONG);<br>
- if (_v) {<br>
+ if (Z_TYPE_PP(argv[0]) == IS_RESOURCE) {<br>
return<br>
_wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU);<br>
}<br>
}<br>
<br>
<br>
<br>
regards<br>
Helmut<br>
<div><div></div><div><br>
<br>
On 17.06.2010 09:55, Helmut Kuper wrote:<br>
> Hi,<br>
><br>
> a bit success now. When I use this command:<br>
><br>
> $con = new ESLconnection(intval($csock));<br>
><br>
> I got an ESLconnection object, but it is not usable. var_dump($con) shows<br>
><br>
> object(ESLconnection)#1 (1) {<br>
> ["_cPtr"]=><br>
> resource(7) of type (_p_ESLconnection)<br>
> }<br>
><br>
><br>
> which looks good to me, but strace still shows "Bad file descriptor":<br>
><br>
> setsockopt(6, SOL_TCP, TCP_NODELAY, [1], 4) = -1 EBADF (Bad file descriptor)<br>
> sendto(6, "connect\n\n", 9, 0, NULL, 0) = -1 EBADF (Bad file descriptor)<br>
><br>
> Calling $con->getINFO() results in NULL ...<br>
><br>
><br>
> regards<br>
> Helmut<br>
><br>
> _______________________________________________<br>
> FreeSWITCH-users mailing list<br>
> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
> <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
><br>
><br>
<br>
</div></div>--<br>
<br>
Mit freundlichen Grüßen<br>
Helmut Kuper<br>
Geschäftseinheit FD - Lösungen für Finanzdienstleister<br>
Telefax: (0441) 8000-2799<br>
mailto:<a href="mailto:helmut.kuper@ewetel.de" target="_blank">helmut.kuper@ewetel.de</a><br>
___________________________________<br>
EWE TEL GmbH<br>
Cloppenburger Straße 310<br>
26133 Oldenburg<br>
EWE TEL GmbH<br>
<br>
Handelsregister Amtsgericht Oldenburg HRB 3723<br>
Vorsitzender des Aufsichtsrates: Dr. Werner Brinker<br>
Geschäftsführung: Hans-Joachim Iken (Vorsitzender),<br>
Ulf Heggenberger, Dr. Norbert Schulz, Dirk Thole<br>
Homepage: <a href="http://www.ewetel.de" target="_blank">http://www.ewetel.de</a><br>
___________________________________<br>
<div><div></div><div><br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:+19193869900<br>
</div>