socket一般是用于长连接请求,但socket同样可以用于HTTP这样的短连接请求,只不过在请求之后要关闭连接。
使用socket主要分为两部:1.连接服务器 2.发送和接收数据
1.连接服务器:
连接服务器2.发送和接收数据:
发送和接收数据请求并加载百度网页
demo地址:https://gitee.com/liangsenliangsen/socketQingQiuBaiDuWangYe.git
本篇文章到这里就结束了,愿大家加班不多工资多,男同胞都有女朋友,女同胞都有男朋友。😊
网友评论
Bdpagetype: 1
Bdqid: 0x96a9032a0000e05d
Cache-Control: private
Content-Type: text/html
Cxy_all: baidu+aa55ea1a51f31b29ad68537a6cd79fbc
Date: Mon, 09 Jul 2018 03:14:24 GMT
Expires: Mon, 09 Jul 2018 03:13:49 GMT
P3p: CP=" OTI DSP COR IVA OUR IND COM "
Server: BWS/1.1
Set-Cookie: BAIDUID=15C0B6E0223A9DF665551FC473126765:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BIDUPSID=15C0B6E0223A9DF665551FC473126765; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: PSTM=1531106064; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BDSVRTM=0; path=/
Set-Cookie: BD_HOME=0; path=/
Set-Cookie: H_PS_PSSID=1462_21099_18559_26809; path=/; domain=.baidu.com
Vary: Accept-Encoding
X-Ua-Compatible: IE=Edge,chrome=1
Connection: close
Transfer-Encoding: chunked