简体   繁体   English

RDP通过蓝牙

[英]RDP through Bluetooth

This is a R&D project. 这是一个研发项目。 Stream Windows PC's desktop to mobile phone on Bluetooth. 通过蓝牙将Windows PC的桌面流式传输到手机上。 I am successful in streaming desktop to my Android phone with 720p but the thing is I am unable to get live stream. 我成功将桌面流式传输到我的Android手机720p,但问题是我无法获得直播。 Encoding and Data going over Bluetooth take some milliseconds, so it is not that live. 通过蓝牙进行编码和数据需要几毫秒,所以它不是那么活。 So what I did, I chose RDP for this. 所以我做了什么,我为此选择了RDP。 As RDP is only built for LAN. 由于RDP仅适用于LAN。 I have no profile for PAN. 我没有PAN的个人资料。 I wrote a proxy which only routes RDP packets from localhost to my computer over bluetooth. 我写了一个代理,它只通过蓝牙将RDP数据包从localhost路由到我的电脑。 On Computer side there is another program running which takes data from bluetooth and sends this data to localhost port 3389. Now the problem I am facing is that, as connection initiated, socket gets close itself. 在计算机端,还有另一个程序正在运行,该程序从蓝牙获取数据并将此数据发送到localhost端口3389.现在我面临的问题是,当连接启动时,套接字会自行关闭。 The program only reads 80 or 45 bytes initially, then exception occurs "Socket Closed". 程序最初只读取80或45个字节,然后发生异常“Socket Closed”。 My question is, does RDP open and close sockets for a session, or connects for the first time and then use that socket. 我的问题是,RDP是否为会话打开和关闭套接字,或者是第一次连接然后使用该套接字。 As I am new to this RDP thing. 因为我是这个RDP的新手。 suggest me some topic about RDP. 建议我一些关于RDP的话题。 Any help is highly appreciated. 任何帮助都非常感谢。

regards Moonzai 关于Moonzai

UPDATE: 更新:

I am using following code for reading and writting to and from Bluetooth and Socket. 我正在使用以下代码来读取和写入蓝牙和套接字。

  class ReadWrite implements Runnable {

    private String name;

    private Thread thread;
    private InputStream is;
    private OutputStream os;

    private volatile boolean start = false;

    public ReadWrite(String name, InputStream is, OutputStream os) {
        this.name = name;
        this.is = is;
        this.os = os;
        thread = new Thread(this);
    }

    public void startThread() {
        start = true;
        thread.start();
    }

    public void stopThread() {
        start = false;
        try {
            if (is != null) {
                is.close();
            }

            if (os != null) {
                os.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void run() {
        System.out.println(name + " ReadWrite Started");

        byte[] buffer = new byte[8092];
        int read;

        while (start) {
            try {
                read = is.read(buffer);
                System.out.println(name + " Read: " + read);
                if (read > 0) {
                    os.write(buffer, 0, read);
                    os.flush();
                }
            } catch (Exception e) {
                e.printStackTrace();
                break;
            }
        }

        System.out.println(name + " ReadWrite Stopped");
    }
}

I am starting 2 instances of this thread like: 我开始这个线程的2个实例,如:

  ReadWrite bt2net = new ReadWrite("bt2net", btis, netos);
  ReadWrite net2bt = new ReadWrite("net2bt", netis, btos);
  bt2net.startThread();
  net2bt.startThread();

where btis , netos , netis and btos are InputStream and OutputStream . 其中btisnetosnetisbtosInputStreamOutputStream This class is used on both sides Android and PC. 此类用于Android和PC两侧。 PC side runs with read length of -1 whereas Android side gives me this exception: PC端的读取长度为-1,而Android端则给出了这个异常:

  java.net.SocketException: Socket closed
  java.io.IOException: bt socket closed, read return: -1

I dont what and why this is happening. 我不知道为什么会发生这种情况。 Please put some light on RDP low level, as I didn't find any helpful information. 请对RDP低级别有所了解,因为我没有找到任何有用的信息。

Yes, it looks like RDP does open and close sockets when connecting. 是的,看起来RDP在连接时会打开和关闭套接字。 I just did a packet capture of an RDP connection from a Windows Vista computer to a Windows Server 2003 R2 server, and there are two TCP streams. 我刚刚从Windows Vista计算机到Windows Server 2003 R2服务器进行了RDP连接的数据包捕获,并且有两个TCP流。 The first TCP stream consists of 19 bytes one way, then 19 bytes back the other way, similar to how you describe. 第一个TCP流由单向19个字节组成,然后以另一个方式包含19个字节,类似于您描述的方式。 A second later, another TCP connection is set up, and this lasts the length of the session. 一秒钟之后,建立另一个TCP连接,这将持续会话的长度。

Good luck with your project! 祝你的项目好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM