gpt4 book ai didi

VB.Net 仅使用 TCP 获取 1 个图像

转载 作者:可可西里 更新时间:2023-11-01 02:54:50 26 4
gpt4 key购买 nike

我最近决定创建一个应用程序来查看其他计算机的桌面,Os far 我可以看到桌面,但它似乎只发送 1 张图像:?我在客户端使用 TCP 客户端和一些线程(查看桌面的那个)。当服务器发送图像时,它似乎随后锁定并且变得无响应客户端接收码:

    Private Sub check()
If sock.Connected = True Then
sock.SendTimeout = 5000
Try
Application.DoEvents()
Dim nstream As NetworkStream
Dim bf As New BinaryFormatter
nstream = sock.GetStream
PictureBox1.Image = Nothing
PictureBox1.Image = bf.Deserialize(nstream)
If nstream.DataAvailable = True Then
MsgBox(nstream)
End If
Catch ex As Exception
check()
End Try
End If
End Sub

然后这是发送它的代码发送代码:

    Public Function Desktop() As Image
Dim bounds As Rectangle = Nothing
Dim screenshot As System.Drawing.Bitmap = Nothing
Dim graph As Graphics = Nothing
bounds = Screen.PrimaryScreen.Bounds
screenshot = New Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
Return screenshot
End Function

Private Sub SendDesk()
If sock.Connected = True Then
Try
Dim nstream As NetworkStream
Dim bf As New BinaryFormatter
nstream = sock.GetStream
bf.Serialize(nstream, Desktop())
Catch ex As Exception
End Try
End If
End Sub

我已经在 Vb.net 中编码了一段时间(基本的东西,一些 HTTP 的东西)但是我是 TCP 和网络流的新手,非常感谢任何帮助,谢谢!

最佳答案

需要重复图片发送过程...

While sock.Connected = True
Try
Dim nstream As NetworkStream
Dim bf As New BinaryFormatter
nstream = sock.GetStream
bf.Serialize(nstream, Desktop())
Catch ex As Exception
End Try
End While

关于VB.Net 仅使用 TCP 获取 1 个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14056024/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com