我只是尝试使用Udp协议发送屏幕截图这是代码:

private void Form1_Load(object sender, EventArgs e)
    {

        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
       ProtocolType.Udp);

        IPAddress broadcast = IPAddress.Parse("10.0.0.4");

        Bitmap bitmap=GetDesktopImage();//generate screenshot.
        byte[] sendbuf = imageToByteArray(bitmap);
        IPEndPoint ep = new IPEndPoint(broadcast, 10);

        s.SendTo(sendbuf, ep);

        Console.WriteLine("Message sent to the broadcast address");

    }

ImageToByteArray是一个将图像转换为字形数组的函数,您可以看到here .

但是,当使用以下错误详细信息执行 s.SendTo() 行时,我得到一个奇怪的异常:

在数据报套接字上发送的消息大于内部消息缓冲区或其他一些网络限制,或者用于接收数据报的缓冲区小于数据报本身

我不确定,但我认为这与发送的数据大小有关..有什么帮助吗?