Socket與ServerSocket遠端桌面

2021-09-02 04:13:28 字數 1136 閱讀 7991

目的:通過socket與socketserver的通訊實現遠端監控

首先,在serversocket(被監控端)一直截圖傳送到socket。

再到socket(客戶端)中不斷接收截圖內容並展示出來。

**如下:

伺服器:

public class remoteserver  catch (ioexception e) 	}}

class sendthread extends thread catch (exception e)

} public void run()

} catch (exception e)

}}

客戶端:

重寫重繪的方法。

public class remoteclient extends jframe  catch (unknownhostexception e)  catch (ioexception e) 

new remoteclient(socket);

} /**

* create the frame.

*/public remoteclient(socket socket) catch (ioexception e)

setdefaultcloseoperation(jframe.exit_on_close);

setbounds(0, 0, 1200, 700);

contentpane = new mypanel();

jscrollpane jsp = new jscrollpane(contentpane);

jsp.setautoscrolls(true);

add(jsp);

setvisible(true);

new receive().start();

} /**

* 接收伺服器的

* * @author huangbin

* @date 2023年7月31日

*/class receive extends thread

} catch (exception e1)

} }class mypanel extends jpanel

}}

非同步SOCKET與同步SOCKET

windows 套接字在兩種模式下執行 i o操作,阻塞和非阻塞。在阻塞模式下,在 i o操作完成前,執行操作的 winsock 函式會一直等待下去,不會立即返回程式 將控制權交還給程式 而在非阻塞模式下,winsock 函式無論如何都會立即返回。windows sockets 的非同步選擇函式 w...

Socket通訊協議與socket安全

作者為 qq 37551067 在socket強聯網中,我們可以通過定義一些對資料封裝的規則來進行資料的傳輸,讓資料可以在伺服器和客戶端進行 相互傳輸 每條資料都有乙個協議編號,在資料傳輸的時候也一併傳輸過去,讓接受方可以知道傳輸的是哪個協議,可以使用對應 一就是json不支援float型別的數據,...

Socket 原理與使用

1.什麼是 tcp ip udp?2.socket在 呢?3.socket是什麼呢?4.你會使用它們嗎?什麼是tcp ip udp?tcp ip transmission control protocol internet protocol 即傳輸控制協議 網間協議,是乙個工業標準的協議集,它是為廣...