写的一个demo,建立Socket连接之后,循环发送电脑屏幕截图
服务器端开启之后监听端口号2000,为新建连接创建新的Socket。之后从客户端接收截图,判断一张图片接收结束之后。将图片显示于pictureBox控件上。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace server
{
public partial class Form1 : Form
{
public Thread mythread;
public int shu = 0;
public Form1()
{
InitializeComponent();
// CheckForIllegalCrossThreadCalls = false; 不需要
}
public Socket nect(int port, string host)
{
IPAddress ip = IPAddress.Parse(host);
IPEndPoint ipe = new IPEndPoint(ip, port);
Socket s = new Socket(AddressFamily.InterNetwork