PHP怎么向某个IP的某个端口发送一个字节
Jun 13, 2016 pm 01:32 PM
PHP如何向某个IP的某个端口发送一个字节?
如题,比如向202.117.120.241的2012端口发送一个字节,字节的8位分别是00100000,该怎样实现?
------解决方案--------------------
$fp = fsoctopen('202.117.120.241', 2012);
fwrite($fp, chr(bindec('00100000')));
------解决方案--------------------
fsocketopen();
------解决方案--------------------
晕啊。。
fsockopen();
------解决方案--------------------
- PHP code
$fp = fsockopen('202.117.120.241', 2012, $ercode, $ermsg); if($ercode !== 0) exit ('error:'. $ermsg); $st = sprintf("%b", 00100000); fread($fp, $st); <br><font color="#e78608">------解决方案--------------------</font><br>这是可能由于202.117.120.241这个机子没有监听2012端口。这不是代码的问题造成的。<br>另外我写的<br>$st = sprintf("%b", 00100000); 是错误的。我对二进制字节的理解有误,1楼是正确的 <div class="clear"> </div>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Simplified HTTP Response Mocking in Laravel Tests

Build a React App With a Laravel Back End: Part 2, React

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
