zoukankan      html  css  js  c++  java
  • perl socket 获取响应信息

    package mojo::Client::SMSsendx;
        use IO::Socket::INET;
        use Data::Dumper;
        use Encode;
    sub SMSsendx {
        $|=1;
        $sock = IO::Socket::INET->new(PeerAddr => '10.3.229.1',
                                       PeerPort => '745',
                                       Proto=>'tcp'
                                   ) or die "$!
    ";
       my $self=shift;
       my $message=shift;
       my $phone=shift;
       print "sock$message is $message
    ";
      my $tab=chr(9);
      #my $data=0Xd$tab;
      my $data=chr(28).chr(48).chr(88).chr(100)."$tab";
         $data .="015802$tab";
         $data .="$tab";
         $data .="N$tab";
         $data .="$message$tab";
         $data .="$phone$tab";
         print "-----------------
    ";
         print $data."
    ";
         print "-----------------
    ";
         # data to send to a server
          my $req = "$data";
          my $size = $sock->send($req);
          print "sent data of length $size
    ";
         #  # notify server that request has been sent
           shutdown($sock, 1);
         #   # receive a response of up to 1024 characters from server
            my $response = "";
             $sock->recv($response, 1024);
            print "received response: $response
    ";
             $sock->close();
         
      };
    1;

  • 相关阅读:
    struts2笔记之if控制标签
    struts2标签之iterator遍历集合
    struts2获得session和request
    数据库操作语句
    weixinapp api
    struts2笔记之tree标签输出树
    struts2笔记之整合Tiles
    C++中的符号
    JSP布局相关使用
    5.Github仓库
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349792.html
Copyright © 2011-2022 走看看