I’ve ran some tests with sockets (using fsockopen() and stream_socket_client()) and cURL to force closing a connection (TCP/HTTP). However, no luck.
Whether I use a 1ms timeout (on cURL the CURLOPT_TIMEOUT_MS option requires a minimal of 1s anyway) or quit a connection immediately after opening it with blocking disabled, it still works flawless.
I haven’t tried forking (pcntl_fork()) my script, but my server doesn’t support it anyway.
Is there any other way to kill a connection in PHP? It’s quite disappointing you can’t in PHP while you can in C# 🙁
Edit: Let me clarify my question as it might be somewhat confusing:
I want to see if PHP allows developers to send a SYN. That’s all. One, single, SYN packet using PHP’s native functions.
This seems related to another Stack Overflow question about sending raw, low level data via PHP: Want to manually send SYN ACK packets to establish TCP connection (in PHP if possible)
The library mentioned in the answer was prnl which does the job but I haven’t played with too heavily just yet. From the description:
If you’re using PHP via Apache then you’re going to find that Apache has already established a connection before your PHP has a chance to run. I’m not sure at this point if you have the ability to intervene in the handshake at that point.
If this isn’t what you’re looking for please update the question and I’ll see what I can find to get you what you’re looking for.