-
vb教程之用VB的WINSOCK控件发送大于8K的BMP
作者:lcmcome
服务器端:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const theScreen = 1
Private Sub Form_Load()
tcpServer.LocalPort = 1001 ' 设置监听端口号
tcpServer.Listen ' 开始监听
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then tcpServer.Close
tcpServer.Accept requestID
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim a As String
tcpServer.GetData a
If a = "b" Then
Call keybd_event(vbKeySnapshot, theScreen, 0, 0)
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
SavePicture Picture1.Image, "d:\ww.bmp"
Dim buf() As Byte
Dim position As Long
Open "d:\ww.bmp" For Binary As #1
position = 0
Do While Not EOF(1)
position = positon + 1
ReDim Preserve buf(1 To position)
Get #1, , buf(position)
Loop
Close #1
tcpServer.SendData buf
End If
End Sub
客户端:
Private Sub Command1_Click()
tcpClient.RemoteHost = txtip.Text
tcpClient.RemotePort = 1001
tcpClient.Connect ' 进行连接
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("d:\wr.bmp")
End Sub
Private Sub Command3_Click()
tcpClient.SendData "b"
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim receivefile(1 To 119862) As Byte
tcpClient.GetData receivefile, vbArray + vbByte
'告诉Winsock控件收到的是字节数组类型的数据
Open "d:\wr.bmp" For Binary As #1
Put #1, , receivefile
Close #1
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
End Sub
Private Sub Text1_Change()
End Sub
服务器端:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const theScreen = 1
Private Sub Form_Load()
tcpServer.LocalPort = 1001 ' 设置监听端口号
tcpServer.Listen ' 开始监听
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then tcpServer.Close
tcpServer.Accept requestID
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim a As String
tcpServer.GetData a
If a = "b" Then
Call keybd_event(vbKeySnapshot, theScreen, 0, 0)
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
SavePicture Picture1.Image, "d:\ww.bmp"
Dim buf() As Byte
Dim position As Long
Open "d:\ww.bmp" For Binary As #1
position = 0
Do While Not EOF(1)
position = positon + 1
ReDim Preserve buf(1 To position)
Get #1, , buf(position)
Loop
Close #1
tcpServer.SendData buf
End If
End Sub
客户端:
Private Sub Command1_Click()
tcpClient.RemoteHost = txtip.Text
tcpClient.RemotePort = 1001
tcpClient.Connect ' 进行连接
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("d:\wr.bmp")
End Sub
Private Sub Command3_Click()
tcpClient.SendData "b"
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim receivefile(1 To 119862) As Byte
tcpClient.GetData receivefile, vbArray + vbByte
'告诉Winsock控件收到的是字节数组类型的数据
Open "d:\wr.bmp" For Binary As #1
Put #1, , receivefile
Close #1
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
End Sub
Private Sub Text1_Change()
End Sub
最新更新
python爬虫及其可视化
使用python爬取豆瓣电影短评评论内容
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比