用PHP的socket实现客户端到服务端的通信实例详解

 更新时间:2017年7月6日 23:50  点击:1503
本文详细介绍了用PHP的socket实现客户端到服务端的通信实例详解,非常实用,有兴趣的同学快来看看吧

一、server.php服务端:

 代码如下 复制代码

<?php

error_reporting(E_ALL);

set_time_limit(0);

ob_implicit_flush();

//本地IP

$address='localhost';

//设置用111端口进行通信

$port= 111;

//创建SOCKET

if(($sock= socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {

    echo"socket创建失败原因 ". socket_strerror($sock) ."\n";

}

  

if(($ret= socket_bind($sock,$address,$port)) < 0) {

    echo"创建套接字失败原因 ". socket_strerror($ret) ."\n";

}

//监听

if(($ret= socket_listen($sock, 5)) < 0) {

    echo"监听失败原因 ". socket_strerror($ret) ."\n";

}

do{

  //接收命令 

  if(($msgsock= @socket_accept($sock)) < 0) {

    echo"命令接收失败原因: ". socket_strerror($msgsock) ."\n";

    break;

  }

  $msg="\nPHP Test Server. \n"."用quit,shutdown,sun...等命令测试.\n";

  

  @socket_write($msgsock,$msg,strlen($msg));

  

  do{

    if(false === ($buf= @socket_read($msgsock, 2048, PHP_NORMAL_READ))) {

        echo"socket_read() failed: reason: ". socket_strerror($ret) ."\n";

        break2;

    }

    if(!$buf= trim($buf)) {

        continue;

    }

    if($buf=='quit') {

        break;

    }

    if($buf=='shutdown') {

        socket_close($msgsock);

        break2;

    }

    if($buf=='sun') {

        echo'what are you doing?';

    }

    $talkback="Backinformation : '$buf'.\n";

    socket_write($msgsock,$talkback,strlen($talkback));

    echo"$buf\n";

  }while(true);

  

  socket_close($msgsock);

  

}while(true);

  

socket_close($sock);

?>

二、client.php客户端:

 代码如下 复制代码

<?php

error_reporting(E_ALL);

//端口111

$service_port= 111;

//本地

$address='localhost';

//创建 TCP/IP socket

$socket= socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

if($socket< 0) {

    echo"socket创建失败原因: ". socket_strerror($socket) ."\n";

}else{

    echo"OK,HE HE.\n";

}

$result= socket_connect($socket,$address,$service_port);

if($result< 0) {

    echo"SOCKET连接失败原因: ($result) ". socket_strerror($result) ."\n";

}else{

    echo"OK.\n";

}

//发送命令

$in="HEAD / HTTP/1.1\r\n";

$in.="Connection: Close\r\n\r\n";

$out='';

echo"Send Command..........";

$in="sun\n";

socket_write($socket,$in,strlen($in));

echo"OK.\n";

echo"Reading Backinformatin:\n\n";

while($out= socket_read($socket, 2048)) {

    echo$out;

}

echo"Close socket........";

socket_close($socket);

echo"OK,He He.\n\n";

?>

这两段代码是简单介绍用PHP实现客户端和服务端的通信

具体操作,在DOS下用PHP命令打开SERVER,处于监听状态..

再打开一个DOS窗口,用PHP命令打开CLIENT,会得到服务端的回应....

本文介绍了详谈PHP中的密码安全性Password Hashing,非常实用,不会的同学可以参考一下

如果你还在用md5加密,建议看看下方密码加密和验证方式。

先看一个简单的Password Hashing例子:

 代码如下 复制代码

<?php

 

//require 'password.php';

/**

 * 正确的密码是secret-password

 * $passwordHash 是hash 后存储的密码

 * password_verify()用于将用户输入的密码和数据库存储的密码比对。成功返回true,否则false

 */

$passwordHash= password_hash('secret-password', PASSWORD_DEFAULT);

echo$passwordHash;

if(password_verify('bad-password',$passwordHash)) {

  // Correct Password

  echo'Correct Password';

}else{

  echo'Wrong password';

  // Wrong password

}

下方代码提供了一个完整的模拟的 User 类,在这个类中,通过使用Password Hashing,既能安全地处理用户的密码,又能支持未来不断变化的安全需求。

 代码如下 复制代码

<?php

classUser

{

  // Store password options so that rehash & hash can share them:

  constHASH = PASSWORD_DEFAULT;

  constCOST = 14;//可以确定该算法应多复杂,进而确定生成哈希值将花费多长时间。(将此值视为更改算法本身重新运行的次数,以减缓计算。)

 

  // Internal data storage about the user:

  public$data;

 

  // Mock constructor:

  publicfunction__construct() {

    // Read data from the database, storing it into $data such as:

    // $data->passwordHash and $data->username

    $this->data =newstdClass();

    $this->data->passwordHash ='dbd014125a4bad51db85f27279f1040a';

  }

 

  // Mock save functionality

  publicfunctionsave() {

    // Store the data from $data back into the database

  }

 

  // Allow for changing a new password:

  publicfunctionsetPassword($password) {

    $this->data->passwordHash = password_hash($password, self::HASH, ['cost'=> self::COST]);

  }

 

  // Logic for logging a user in:

  publicfunctionlogin($password) {

    // First see if they gave the right password:

    echo"Login: ",$this->data->passwordHash,"\n";

    if(password_verify($password,$this->data->passwordHash)) {

      // Success - Now see if their password needs rehashed

      if(password_needs_rehash($this->data->passwordHash, self::HASH, ['cost'=> self::COST])) {

        // We need to rehash the password, and save it. Just call setPassword

        $this->setPassword($password);

        $this->save();

      }

      returntrue;// Or do what you need to mark the user as logged in.

    }

    returnfalse;

  }

}

小编介绍的这篇文章写了php、mysql查询当天,查询本周,查询本月的数据实例,非常实用,不会的同学可以参考一下。

php、mysql查询当天,查询本周,查询本月的数据实例(字段是时间戳)

 代码如下 复制代码

//其中 video 是表名;

//createtime 是字段;

//

//数据库time字段为时间戳

//

//查询当天:

 

$start=date('Y-m-d 00:00:00');

$end=date('Y-m-d H:i:s');

SELECT * FROM `table_name` WHERE `time` >= unix_timestamp('$start') AND `time` <= unix_timestamp('$end')

 

//查询本周:

 

SELECT yearweek('2011-04-17 15:38:22',1 )//结果是201115

SELECT yearweek('2011-04-17 15:38:22')//结果是201116

//yearweek的第2个参数设置为1的原因是,中国人习惯把周1作为本周的第一天

//另外补充下:

//2011-04-17 是周日。

SELECT dayofweek('2011-04-17 15:38:22')// 查询出的是1,把礼拜天作为一周的第一天。

SELECT dayofweek('2011-04-18 15:38:22')//查询出的是2

SELECT weekday('2011-04-17 15:38:22')// 查询出的是6,

SELECT weekday('2011-04-18 15:38:22')// 查询出的是0,

//所以建议使用weekday,查询出来的结果+1就可以了,就比较符合国人的习惯了。

 

SELECT * FROM `table_name` WHERE YEARWEEK( FROM_UNIXTIME( `time`,'%Y-%m-%d %H:%i:%s') ,1) = YEARWEEK( now( ),1 )

 

//查询本月:

 

$start=date('Y-m-01 00:00:00');

$end=date('Y-m-d H:i:s');

SELECT * FROM `table_name` WHERE `time` >= unix_timestamp('&rdquo;.$start.&rdquo;') AND `time` <= unix_timestamp('$end')

 

//查询本年:

 

$start=date('Y-01-01 00:00:00');

$end=date('Y-m-d H:i:s');

SELECT * FROM `table_name` WHERE `time` >= unix_timestamp('$start') AND `time` <= unix_timestamp('$end')

php 获取今日、昨日、上周、本月的起始时间戳和结束时间

 代码如下 复制代码

<?php

//<!--php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法,主要使用到了 php 的时间函数 mktime()。-->

 

 

//1、php获取今日开始时间戳和结束时间戳

 

$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));

$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;

 

echo$beginToday.'---'.$endToday;

echo'<br/>';

//2、php获取昨日起始时间戳和结束时间戳

 

$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));

$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;

 

echo$beginYesterday.'---'.$endYesterday;

echo'<br/>';

//3、php获取上周起始时间戳和结束时间戳

 

$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));

$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));

 

echo$beginLastweek.'---'.$endLastweek;

echo'<br/>';

 

//4、php获取本月起始时间戳和结束时间戳

 

$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));

$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'));

 

echo$beginThismonth.'---'.$endThismonth;

echo'<br/>';

 

 

//PHP mktime() 函数用于返回一个日期的 Unix 时间戳。

//语法:mktime(hour,minute,second,month,day,year,is_dst)

//

//参数    描述

//hour    可选。规定小时。

//minute    可选。规定分钟。

//second    可选。规定秒。

//month    可选。规定用数字表示的月。

//day    可选。规定天。

//year    可选。规定年。在某些系统上,合法值介于 1901 - 2038 之间。不过在 PHP 5 中已经不存在这个限制了。

//is_dst可选。如果时间在日光节约时间(DST)期间,则设置为1,否则设置为0,若未知,则设置为-1。

//自 5.1.0 起,is_dst 参数被废弃。因此应该使用新的时区处理特性。参数总是表示 GMT 日期,因此 is_dst 对结果没有影响。

//

//参数可以从右到左依次空着,空着的参数会被设为相应的当前 GMT 值。

 

echo(date("M-d-Y",mktime(0,0,0,12,36,2001)));

 

//将输出结果如:

//

//Jan-05-2002

小编推荐的这篇文章介绍了PHP水印类,支持添加图片、文字、填充颜色区域的实现,非常实用,有兴趣的同学可以参考一下。

*自己整理的一个水印类*

支持添加图片、文字、填充颜色区域

 代码如下 复制代码

<?php

/**

 * 图片加水印类,支持文字水印、透明度设置、自定义水印位置等。

 * 使用示例:

 *   $obj = new WaterMask($imgFileName);       //实例化对象

 *   $obj->$waterType = 1;           //类型:0为文字水印、1为图片水印

 *   $obj->$transparent = 45;         //水印透明度

 *   $obj->$waterStr = 'icp.niufee.com';        //水印文字

 *   $obj->$fontSize = 18;           //文字字体大小

 *   $obj->$fontColor = array(255,255,255);        //水印文字颜色(RGB)

 *   $obj->$fontFile = 'AHGBold.ttf';       //字体文件

 *   &hellip;&hellip;

 *   $obj->output();              //输出水印图片文件覆盖到输入的图片文件

 * @modify liuzp111

 */

classWaterMask{

  public$waterTypeImage  = false;               //水印类型:启用图片水印

  public$waterTypeStr   = false;         //水印类型:启用文字水印

  public$pos       = 0;         //水印位置

  public$transparent   = 45;        //水印透明度(0---100)数值越大越不透明

 

  public$waterStr     ='icp.niufee.com';     //水印文字

  public$fontSize     = 14;        //文字字体大小

  public$fontColor    =array(0,0,0);         //水印文字颜色(RGB) 默认黑色

  public$fontFile     ='./font/simfang.ttf';     //字体文件

 

  public$waterImg     ='logo.png';      //水印图片

 

  private$srcImg      ='';        //需要添加水印的图片

  private$im        ='';        //图片句柄

  private$water_im     ='';        //水印图片句柄

  private$srcImg_info   ='';        //图片信息

  private$waterImg_info  ='';        //水印图片信息

  private$str_w      ='';        //水印文字宽度

  private$str_h      ='';        //水印文字高度

  private$x        ='';        //水印X坐标

  private$y        ='';        //水印y坐标

  public$output_img    ='';                 //存储输出图片到哪里

  public$is_draw_rectangle= false;                 //是否绘制矩形区域 (暂不支持自定义位置)

  //public $rectange_color   = '';                  //绘制矩形区域的颜色 

  private$result_array   =array();              //结果数组

  publicfunction__construct($img) {   //析构函数

    //$this->srcImg = file_exists($img) ? $img : die('"'.$img.'" 源文件不存在!');

    if(file_exists($img)){

      $this->srcImg =$img;

    }else{

      returnarray('data'=>'','info'=>'源文件不存在!','status'=>0);

    }

  }

 

  privatefunctionimginfo() { //获取需要添加水印的图片的信息,并载入图片。

    $this->srcImg_info =getimagesize($this->srcImg);

    switch($this->srcImg_info[2]) {

      case3:

        $this->im = imagecreatefrompng($this->srcImg);

        break1;

      case2:

        $this->im = imagecreatefromjpeg($this->srcImg);

        break1;

      case1:

        $this->im = imagecreatefromgif($this->srcImg);

        break1;

      default:

        //die('原图片('.$this->srcImg.')格式不对,只支持PNG、JPEG、GIF。');

        returnarray('data'=>'','info'=>'原图片('.$this->srcImg.')格式不对,只支持PNG、JPEG、GIF。','status'=>0);

    }

  }

 

  privatefunctionwaterimginfo() { //获取水印图片的信息,并载入图片。

    $this->waterImg_info =getimagesize($this->waterImg);

    switch($this->waterImg_info[2]) {

      case3:

        $this->water_im = imagecreatefrompng($this->waterImg);

        break1;

      case2:

        $this->water_im = imagecreatefromjpeg($this->waterImg);

        break1;

      case1:

        $this->water_im = imagecreatefromgif($this->waterImg);

        break1;

      default:

        //die('水印图片('.$this->srcImg.')格式不对,只支持PNG、JPEG、GIF。');

         returnarray('data'=>'','info'=>'水印图片('.$this->srcImg.')格式不对,只支持PNG、JPEG、GIF。','status'=>0);

    }

  }

  privatefunctionwaterpos() { //水印位置算法

    switch($this->pos) {

      case0:  //随机位置

        $this->x = rand(0,$this->srcImg_info[0]-$this->waterImg_info[0]);

        $this->y = rand(0,$this->srcImg_info[1]-$this->waterImg_info[1]);

        break1;

      case1:  //上左

        $this->x = 0;

        $this->y = 0;

        break1;

      case2:  //上中

        $this->x = ($this->srcImg_info[0]-$this->waterImg_info[0])/2;

        $this->y = 0;

        break1;

      case3:  //上右

        $this->x =$this->srcImg_info[0]-$this->waterImg_info[0];

        $this->y = 0;

        break1;

      case4:  //中左

        $this->x = 0;

        $this->y = ($this->srcImg_info[1]-$this->waterImg_info[1])/2;

        break1;

      case5:  //中中

        $this->x = ($this->srcImg_info[0]-$this->waterImg_info[0])/2;

        $this->y = ($this->srcImg_info[1]-$this->waterImg_info[1])/2;

        break1;

      case6:  //中右

        $this->x =$this->srcImg_info[0]-$this->waterImg_info[0];

        $this->y = ($this->srcImg_info[1]-$this->waterImg_info[1])/2;

        break1;

      case7:  //下左

        $this->x = 0;

        $this->y =$this->srcImg_info[1]-$this->waterImg_info[1];

        break1;

      case8:  //下中

        $this->x = ($this->srcImg_info[0]-$this->waterImg_info[0])/2;

        $this->y =$this->srcImg_info[1]-$this->waterImg_info[1];

        break1;

      case9:  //下中偏上100px

        $this->x = ($this->srcImg_info[0]-$this->waterImg_info[0])/2;

        $this->y =$this->srcImg_info[1]-$this->waterImg_info[1] - 100;

        break1;

      default: //下右

        $this->x =$this->srcImg_info[0]-$this->waterImg_info[0];

        $this->y =$this->srcImg_info[1]-$this->waterImg_info[1];

        break1;

    }

  }

  /**

   * 水印文字图片位置,根据需求调整

   */

  privatefunctionwaterposStr() {

    $this->x = ($this->srcImg_info[0]-$this->waterImg_info[0])/2;

    $this->y =$this->srcImg_info[1]-$this->waterImg_info[1] - 3;   

  }

  privatefunctionwaterimg($type='') {

    if($this->srcImg_info[0] <=$this->waterImg_info[0] ||$this->srcImg_info[1] <=$this->waterImg_info[1]){

      //die('水印比原图大!');

      returnarray('data'=>'','info'=>'水印比原图大!','status'=>0);

    }

    if($type=='waterstr'){

      $this->waterposStr();

    }else{

      $this->waterpos();

    }

    $cut= imagecreatetruecolor($this->waterImg_info[0],$this->waterImg_info[1]);

    imagecopy($cut,$this->im,0,0,$this->x,$this->y,$this->waterImg_info[0],$this->waterImg_info[1]);

    $pct=$this->transparent;

    imagecopy($cut,$this->water_im,0,0,0,0,$this->waterImg_info[0],$this->waterImg_info[1]);

    imagecopymerge($this->im,$cut,$this->x,$this->y,0,0,$this->waterImg_info[0],$this->waterImg_info[1],$pct);

  }

 

  privatefunctionwaterstr() {

    $rect= imagettfbbox($this->fontSize,0,$this->fontFile,$this->waterStr);

    $w=abs($rect[2]-$rect[6]);

    $h=abs($rect[3]-$rect[7]);

    $fontHeight=$this->fontSize;

    $this->water_im = imagecreatetruecolor($w,$h);

    imagealphablending($this->water_im,false);

    imagesavealpha($this->water_im,true);

    $white_alpha= imagecolorallocatealpha($this->water_im,255,255,255,127);

    imagefill($this->water_im,0,0,$white_alpha);

    $color= imagecolorallocate($this->water_im,$this->fontColor[0],$this->fontColor[1],$this->fontColor[2]);

    imagettftext($this->water_im,$this->fontSize,0,0,$this->fontSize,$color,$this->fontFile,$this->waterStr);

    $this->waterImg_info =array(0=>$w,1=>$h);

    $this->waterimg($type='waterstr');

  }

  /**

   * 绘制矩形区

   * bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )

   * bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )

   * @author liuzp111

   */

  publicfunctiondrawRectangle()

  {

    //imagefill($im,0,0,$gray);//填充资源,填充的坐标(类似PS魔棒),颜色

    /*

     *  1--------------画长方形--------------

     *  bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )

     *  参数: 画布资源, 左上角x坐标,左上y坐标,右下x坐标,右下y坐标,颜色

     */

    $color= imagecolorallocate($this->im,255,255,255);//创建矩形边框颜色和填充颜色

    //=========================================================================

    //绘制矩形区域并填充

    // 参数说明:

    //bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )

    // im:为将图像载入为图像资源

    // $x1:表示矩形左上角的X坐标

    // $y1:表示矩形左上角的Y坐标

    // $x2:表示矩形右下角的X坐标

    // $y2:表示矩形右下角的Y坐标

    // $color:为填充的RGB颜色

    //

    imagefilledrectangle($this->im,3,$this->srcImg_info[1] - 20,$this->srcImg_info[0]-3,$this->srcImg_info[1]-3,$color);

    //不要使用下方的函数填充,下方填充函数为魔棒填充,容易导致填充不完整

    //imagefill($this->im,$this->srcImg_info[0]/2,$this->srcImg_info[1]-8,$color);//填充资源,填充的坐标(魔棒),颜色

 

  }

  functionoutput() {

    $this->imginfo();

    //是否创建矩形区域

    if($this->is_draw_rectangle){

      $this->drawRectangle();

    }

    if($this->waterTypeStr ) {

      $this->waterstr();

    }

    if($this->waterTypeImage )

    {

      $this->waterimginfo();

      $this->waterimg();

    }

    switch($this->srcImg_info[2]) {

      case3:

        $res_output= imagepng($this->im,$this->output_img);

        break1;

      case2:

        $res_output= imagejpeg($this->im,$this->output_img);

        break1;

      case1:

        $res_output= imagegif($this->im,$this->output_img);

        break1;

      default:

        // die('添加水印失败!');

        returnarray('data'=>'','info'=>'添加水印失败!','status'=>0);

        break;

    }

    imagedestroy($this->im);

    imagedestroy($this->water_im);

    returnarray('data'=>$res_output,'info'=>'添加水印成功!','status'=>1);

  }

}

使用方式:

 代码如下 复制代码

$file='58368dddc8c51_22';//需要加水印的图片

$file_ext='.jpeg';//扩展名

$imgFileName='./'.$file.$file_ext;//需要加水印图片路径

$obj=newWaterMask($imgFileName);//实例化对象

$obj->waterTypeStr = true;    //开启文字水印     

$obj->waterTypeImage = true;   //开启图片水印 

$obj->pos = 9;        //定义水印图片位置

$obj->waterImg ='./water.png';     //水印图片    

$obj->transparent = 100;         //水印透明度

$obj->waterStr ='保险经纪人:刘测试 电话:02052552';      //水印文字

$obj->fontSize = 9;           //文字字体大小

$obj->fontColor =array(0,0,0);       //水印文字颜色(RGB)

$obj->fontFile ='./font/msyh.ttc';   //字体文件,这里是微软雅黑

$obj->is_draw_rectangle = TRUE;     //开启绘制矩形区域

$obj->output_img ='./'.$file.'_n'.$file_ext;//输出的图片路径

$obj->output(); 

[!--infotagslink--]

相关文章

  • php语言实现redis的客户端

    php语言实现redis的客户端与服务端有一些区别了因为前面介绍过服务端了这里我们来介绍客户端吧,希望文章对各位有帮助。 为了更好的了解redis协议,我们用php来实现...2016-11-25
  • jQuery+jRange实现滑动选取数值范围特效

    有时我们在页面上需要选择数值范围,如购物时选取价格区间,购买主机时自主选取CPU,内存大小配置等,使用直观的滑块条直接选取想要的数值大小即可,无需手动输入数值,操作简单又方便。HTML首先载入jQuery库文件以及jRange相关...2015-03-15
  • JS实现的简洁纵向滑动菜单(滑动门)效果

    本文实例讲述了JS实现的简洁纵向滑动菜单(滑动门)效果。分享给大家供大家参考,具体如下:这是一款纵向布局的CSS+JavaScript滑动门代码,相当简洁的手法来实现,如果对颜色不满意,你可以试着自己修改CSS代码,这个滑动门将每一...2015-10-21
  • jQuery+slidereveal实现的面板滑动侧边展出效果

    我们借助一款jQuery插件:slidereveal.js,可以使用它控制面板左右侧滑出与隐藏等效果,项目地址:https://github.com/nnattawat/slideReveal。如何使用首先在页面中加载jquery库文件和slidereveal.js插件。复制代码 代码如...2015-03-15
  • PHP+jQuery翻板抽奖功能实现

    翻板抽奖的实现流程:前端页面提供6个方块,用数字1-6依次表示6个不同的方块,当抽奖者点击6个方块中的某一块时,方块翻转到背面,显示抽奖中奖信息。看似简单的一个操作过程,却包含着WEB技术的很多知识面,所以本文的读者应该熟...2015-10-21
  • SQLMAP结合Meterpreter实现注入渗透返回shell

    sqlmap 是一个自动SQL 射入工具。它是可胜任执行一个广泛的数据库管理系统后端指印, 检索遥远的DBMS 数据库等,下面我们来看一个学习例子。 自己搭建一个PHP+MYSQ...2016-11-25
  • c# socket网络编程接收发送数据示例代码

    这篇文章主要介绍了c# socket网络编程,server端接收,client端发送数据,大家参考使用吧...2020-06-25
  • PHP实现今天是星期几的几种写法

    复制代码 代码如下: // 第一种写法 $da = date("w"); if( $da == "1" ){ echo "今天是星期一"; }else if( $da == "2" ){ echo "今天是星期二"; }else if( $da == "3" ){ echo "今天是星期三"; }else if( $da == "4"...2013-10-04
  • C#实现Socket通信的解决方法

    这篇文章主要介绍了C#实现Socket通信的解决方法,需要的朋友可以参考下...2020-06-25
  • 详解C# Socket异步通信实例

    本篇文章主要介绍了C# Socket异步通信,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • 详解JS WebSocket断开原因和心跳机制

    这篇文章主要介绍了JS WebSocket断开原因和心跳机制,对websocket感兴趣的同学,可以参考下...2021-05-08
  • 原生js实现fadein 和 fadeout淡入淡出效果

    js里面设置DOM节点透明度的函数属性:filter= "alpha(opacity=" + value+ ")"(兼容ie)和opacity=value/100(兼容FF和GG)。 先来看看设置透明度的兼容性代码: 复制代码 代码如下: function setOpacity(ele, opacity) { if (...2014-06-07
  • C# Socket的TCP通讯的实例代码

    本篇文章主要介绍了C# Socket的TCP通讯,socket通讯方式有两种:同步和异步,详细的介绍了这两种方法,有兴趣的可以了解一下。...2020-06-25
  • python使用socket高效传输视频数据帧(连续发送图片)

    本文主要介绍了python使用socket高效传输视频数据帧(连续发送图片),文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-10-23
  • 微信小程序(应用号)开发新闻客户端实例

    这篇文章主要介绍了微信小程序(应用号)开发新闻客户端实例的相关资料,需要的朋友可以参考下...2016-10-25
  • C语言中send()函数和sendto()函数的使用方法

    这篇文章主要介绍了C语言中send()函数和sendto()函数的使用方法,是C语言入门学习中的基础知识,需要的朋友可以参考下...2020-04-25
  • 在页面中输出当前客户端时间javascript实例代码

    这篇文章主要介绍了在页面中输出当前客户端时间javascript实例代码的相关资料,需要的朋友可以参考下...2016-03-03
  • 客户端实现蓝牙接收(C#)知识总结

    网上有关蓝牙接收的资料很多,使用起来也很简单,但是我觉得还是有必要把这些知识总结下来,蓝牙开发需要用到一个第三方的库InTheHand.Net.Personal.dll,感兴趣的朋友可以了解下,或许对你有所帮助...2020-06-25
  • JS如何实现基于websocket的多端桥接平台

    我们在调试过程使用的工具有:modheader,postman等,但这些工具都会存在的问题:缺少客户端里相应的设备信息;即使将cookie信息复制出来,也是存在过期的问题;多个设备之间切换时不方便;针对这些存在的问题,我基于websocket双向通信的特点,实现了多端桥接管理平台...2021-05-15
  • Android中用HttpClient实现Http请求通信

    本文我们需要解决的问题是如何实现Http请求来实现通信,解决Android 2.3 版本以后无法使用Http请求问题,下面请看正文。 Android开发中使用HttpClient来开发Http程序...2016-09-20