喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

[北京]代朋友公司招聘PHP高级程序员多名

上一主题 下一主题
     
标题: [问题] php 如何调用IPMSG发消息,我有JAVA做的,可以发送  
 
wgllz
注册会员
Rank: 2


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希望大家指导
2007-9-19 02:36 PM#1
查看资料  访问主页  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.020639 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP