开发者

Simple question about sockets PHP

Could you please tell me, what happens in this script:

$conn = fsockopen($server, 43);
fputs($conn, $some_string."\r\n");

What kind of data w开发者_StackOverflow中文版ill be sent to the server? GET? POST? PUT? And how should I do same job with cURL? CURLOPT_whatShouldIWriteHere?

Thanks!


This is not an HTTP request, just a pure TCP/IP data transfer.
As such, it's neither GET nor POST nor any other HTTP verb.


It guess that sends a raw string to the server without any header. I don´t think that CURL will do the same (always send some protocol headers), but you can do the same with netcat

> server=192.168.1.1
> some_string=hello
> nc $server 43 <<.
$some_string
.


It is a tcp socket - no HTTP at all. It will simply send whatever $some_string contains.

If you want to use HTTP, use CURL. See the PHP docs for an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜