cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

(no subject)

From: Zhongxing Ming <zhongxming_at_gmail.com>
Date: Tue, 17 Sep 2013 03:25:43 +0800

Hi Dshah!

Thank you for the reply. I'm not using AF_INET socket. Instead, I
implemented a new socket (AF_SERVAL) that uses name instead of IP address
as the identifier of end node. I know that when programming using C, curl
provides a mechanism that allows you to use your custom socket instead of
the default AF_INET socket, which is basically like:

sockfd = socket(AF_SERVAL, SOCK_STREAM, 0);

curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);

In the opensocket function, you can specify your address format
instead of using IPv4/IPv6 address.

I'm wondering how I could do this in PHP?

Thank you.

Zhongxing

2013/9/10 Dshah <divxtamana_at_gmail.com>

> // connect to the internet using the '192.168.0.100' IP
> $opts = array(
> 'socket' => array(
> 'bindto' => '192.168.0.100:0',
> ),);
>
> // create the context...
> $context = stream_context_create($opts);
> $fp = @stream_socket_client ( $link, $errno, $errstr, 120, STREAM_CLIENT_CONNECT, $context);
>
>
>
> On Fri, Aug 16, 2013 at 9:05 PM, Zhongxing Ming <zhongxming_at_gmail.com>wrote:
>
>> Hi,
>>
>> Could anyone suggest me how to do pass a custom socket to curl using PHP?
>> The socket has a new address family which is neither IPv4 or IPv6. I saw
>> the example of external socket in externalsocket.c and tested the custom
>> socket in externalsocket.c. It worked fine. But I don't know how to let
>> curl use the custom socket in PHP.
>>
>> --
>> Best regards
>>
>> Zhongxing Ming
>>
>>
>>
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>
>>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>

-- 
Best regards
Zhongxing Ming
Dept. of Computer Science & Technology
Room 9-402, East Main Building
Tsinghua University
Beijing 100084, China
Tel: 0086-(0)10-62785822
E-mail: ZhongxMing_at_gmail.com

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2013-09-16