Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6537044
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: Python/Ruby

2012-04-27 18:33:39

function utf82unicode($str)  
{
    return iconv("utf-8", "UCS-2BE", $str);
}
function hex2str($hexstring)  
{
    $str = '';
    for($i = 0, $len = strlen($hexstring); $i < $len; $i++)
    {
        $str .= sprintf("%02X", ord(substr($hexstring, $i, 1)));
    }
    return $str;
}
if($_POST['call'])
{
 $all=$_POST['phone_call'];
}
if($_POST['stop'])
{
 $all=$_POST['tel_uncall'];
}
if($_POST['send'])
{
$num=$_POST['meg_num'];
$msg=$_POST['msg'];
$msg=hex2str(utf82unicode($msg));
$all=$num."+".$msg;
}
$length=100;
$server_ip="192.168.1.50";
$port = 3333;
$sockfd=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)or die("创建失败");
    socket_connect($sockfd,$server_ip,$port)or die("连接失败");
socket_write($sockfd,$all,$length)or die("传送失败");
socket_close($socket);
echo ("");
exit();
?>

阅读(3089) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~