在用户端,他们捕获屏幕截图,然后保存为newImage,然后通过套接字发送到服务器
IPAddress[] ipAddress = Dns.GetHostAddresses("ipaddress");
IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], 5656);
Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.IP);
ImageConverter converter = new ImageConverter();
byte[] sendData = (byte[])converter.ConvertTo(newImage, typeof(byte[]));
clientSock.Send(sendData, 0, 0, SocketFlags.None);
clientSock.Close();
这应该可以将图像发送到VPS。
但是我不确定接收端? 我已经开始了。
Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
sck.Bind(new IPEndPoint(0, 5656));
sck.Listen(0);
byte[] buffer = new byte[1000000];
sck.Receive(buffer, buffer.Length, SocketFlags.None);
Console.WriteLine("Image received");
FileStream fs = File.Create("image.jpg");
fs.Write(buffer, 0, buffer.Length);
fs.Close();