Is it possible to send the source code to the server using php curl?

I am trying to use curl to make a permanent connection, just like websockets .. where, once the connection is established, the client and server simply send small text messages instead of a new HTTP request each time.

For a websocket request, I can do a handshake and receive messages from the server (the connection remains open). only problem is curl not sending anything with the header "HTTP / 1.1".

Each time curl_exec starts up, curl sends "GET / HTTP / 1.1". This is not required after the connection is established.

I can use the custom curl request parameter to send my message, but that would form a header, for example "message / HTTP / 1.1".

It would be great if there was a way to eliminate this "HTTP / 1.1" from the header.

I know php sockets are the best option, but I'm just wondering if there is a hacky way to do this (maybe a websocket client) using curl ..

Any ideas?

+4
source share
1 answer

Curl was developed taking into account the HTTP protocol, which has no status (you open a connection, send a request, wait for a response, and close the connection).

However, you can use curl if you want. You will need to useCURLOPT_CONNECT_ONLY

0
source

Source: https://habr.com/ru/post/1542975/


All Articles