Chvanikoff
Chvanikoff

Reputation: 1329

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 will be sent to the server? GET? POST? PUT? And how should I do same job with cURL? CURLOPT_whatShouldIWriteHere?

Thanks!

Upvotes: 0

Views: 74

Answers (3)

ThiefMaster
ThiefMaster

Reputation: 318468

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.

Upvotes: 1

PeterMmm
PeterMmm

Reputation: 24630

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
.

Upvotes: 1

deceze
deceze

Reputation: 521995

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.

Upvotes: 1

Related Questions