简体   繁体   English

php + curl:发送原始TCP请求

[英]Php+curl: send raw tcp request

Is it possible to send raw tcp data stream using curl with php? 是否可以使用curl和php发送原始tcp数据流? I know that fsockopen/fputs is better choice for such sending, and surely I use them when its possible. 我知道fsockopen / fputs是此类发送的更好选择,并且可以肯定的是,我肯定会使用它们。 But on some servers socket functions are disabled, and curl is enabled. 但是在某些服务器上,套接字功能已禁用,并且启用了curl。 So in such cases it will be very comfortably use curl, of course if its possible at all. 因此,在这种情况下,如果可能的话,当然非常舒适地使用卷曲。 For example I need 例如我需要

$fp = fsockopen($my_ip, $my_port);
fwrite($fp, "test string");

I cant use fsockopen, as it's disabled by server config. 我无法使用fsockopen,因为它已被服务器配置禁用。 Any tips to do it with curl? 有任何技巧可以卷曲吗?

You could use the Telnet option of curl as is done here: Proper and fast way to TELNET in PHP. 您可以按照以下步骤使用curl的Telnet选项: 在PHP中使用TELNET的正确而快速的方法。 Sockets are damn slow or how to TELNET with PHP cURL? 套接字太慢了,或者如何使用PHP cURL进行TELNET?

So you won't drag along the http or ftp or whatever protocol. 因此,您不会拖延http或ftp或任何协议。

After that you may try for yourself. 之后,您可以自己尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM