wgllz
注册会员

UID 98433
精华
0
积分 68
帖子 36
金钱 68 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-9-12
状态 离线
|
php 如何调用IPMSG发消息,我有JAVA做的,可以发送
php 如何调用IPMSG发消息,我有JAVA做的,可以发送
我用JAVA做的可以发送,然后用php做就不行,不知道怎么写,下面是我写的大家看看对不对!
<?php
class Send_IpMsg{
var $socket;
var $IPMSG_SENDMSG = 0x00000020;
function Send_IpMsg(){
try{
if (($this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror($this->socket) . "\n";
}
}
catch(Exception $err){
socket_close($this->socket);
}
}
function send(){
$host = "localhost";
$sender = "System 4";
$msg_content = "welcome system 4!";
$buffer = "1:".date("YmdHis").":".$sender.":".$host+":".$this->IPMSG_SENDMSG.":".$msg_content;
$buffer="1:test:system 4:localhost:0x00000020:welcome system 4!";
$result = socket_connect($this->socket, "192.168.20.135", 2425);
if ($result < 0) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
echo "数据接收成功!";
}
echo $buffer;
socket_write($this->socket, $buffer, strlen($buffer));
}
function close(){
socket_close($this->socket);
}
}
?>
|  陕西培训114网站长
http://www.sxpx114.com
新学php希望大家指导 |
|