Re: question for "translating" fsockopen into CURL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yeni Setiawan wrote:
> dear all.
> 
> I'm currently writing a script that connect to specific IP (server) at a
> specific port (1950).
> then I need to send some parameters and the server will give me a reply.
> 
> too bad, my current webhost no longer accept fsockopen().
> so I need to translate my script into CURL thingie.
> 
> here's my script using fsockopen(), and it run very well:
> 
> <?php
> $ptr=fsockopen("xxx.114.105.87",1950);
> if($ptr){
> 
> fputs($ptr,"WQUOTES-EURUSD,USDJPY,USDCHF,GBPUSD,EURCHF,EURJPY,EURGBP,AUDUSD,NZDUSD,USDCAD,GBPCHF,AUDJPY,GBPJPY,CHFJPY,AUDJPY,NZDUSD\n");
> 
>   echo fgets($ptr,500);
>   fclose($ptr);
>  }
> ?>
> 
> then, I tried following script using CURL:
> 
> <?php
> $ch = curl_init();
> curl_setopt ($ch, CURLOPT_URL, "xxx.114.105.87");
> curl_setopt ($ch, CURLOPT_PORT, "1950");
> curl_setopt ($ch, CURLOPT_CUSTOMREQUEST,
> "WQUOTES-EURUSD,USDJPY,USDCHF,GBPUSD,EURCHF,EURJPY,EURGBP,AUDUSD,NZDUSD,USDCAD,GBPCHF,AUDJPY,GBPJPY,CHFJPY,AUDJPY,NZDUSD\n");
> 
> echo curl_exec ($ch);
> curl_close ($ch);
> ?>
> 
> but it like looping forever and none the result displayed.
> 
> actually I was confused which one to replace fputs() function.
> any response will be great.
> 
you must specify the protocol, curl currently support the http,
https,ftp, gopher, telnet, dict, file, and ldap protocols(see
documenation for more).

if the protocol you use is not supported by curl,  you have to find
another way :(

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux