1
1楼 xhq6632 2010-04-02 <?php
/* * Author:xhq * Email:xhq6632@126.com * Oicq:119948717 */ /*
*发送socket协议函数,取得返回值 *参数:发送的字符串,发送主机,发送端口 *返回值:取得返回字符串 */ function sendto($msg,$host,$port,$debug=false){ $msg=trim($msg); $host=trim($host); $port=trim($port); if(empty($host) || empty($port)){ if($debug){ die("<br>\nhost or port is empty!<br>\nhost={$host} port={$port}"); }else{ die(0); } } $str=""; $msg.="\n"; $socket = socket_create(AF_INET,SOCK_STREAM, SOL_TCP); $connection = socket_connect($socket,$host,$port); if(!socket_write($socket,$msg)){ $str=-1; if($debug){ echo "<br>\nsocket fail!"; } }else{//操作成功 while($buffer = socket_read($socket, 1024, PHP_NORMAL_READ)){ if($debug){ echo("<br>\ncontent=>".$buffer); } } $str=1; } return $str; } ?>
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| |||||