freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

java語(yǔ)言程序設(shè)計(jì)(輸入輸出流、網(wǎng)絡(luò)通信)ppt(編輯修改稿)

2025-11-14 14:50 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 ,以便連到服務(wù)器上 : Socket(host_IP, prot)。 在服務(wù)器端使用 ServerSocket類,以等待客戶端的連接 : ServerSocket(port)。 客戶端呼叫 服務(wù)器等待 31 Socket主要方法: 在客戶端:建立 socket連接后 ,還應(yīng)該建立輸入輸出數(shù)據(jù)流。 getInputStream( ) 獲得輸入流 getOutputStream( ) 獲得輸出流 在服務(wù)器端: ServerSocket類的 accept( )方法使服務(wù)器處于阻塞狀態(tài) ,等待用戶請(qǐng)求。 32 Client Socket(host, port ) Attempt the connection OutputStream InputStream Close Socket 二、 TCP協(xié)議 Socket編程 Server ServerSocket(port ) Server () Socket() OutputStream InputStream Close Socket 33 例 1:演示服務(wù)器與客戶之間的交互 ,服務(wù)器等待 ,客戶訪問(wèn) ,相互通一次信息。 客戶端向服務(wù)器發(fā)出信息:“你好”,服務(wù)器接收到信息后,給出回應(yīng):“你好,我是服務(wù)器?!? 34 Socket . Socket 創(chuàng)建服務(wù)器 (端口號(hào) ) 定義數(shù)據(jù)成員 服務(wù)器等待 網(wǎng)絡(luò)連接 建立 socket流 讀客戶 端信息 向用戶發(fā)出確認(rèn)字符串 創(chuàng)建 Socket實(shí)例 定義數(shù)據(jù)成員 建立 socket流 讀 socket流 (接收并顯示 ) 送用戶名給 服務(wù)器 關(guān)閉流 waiting for user 4331 concting client... 提示用戶登錄成功 讀 socket流 35 客戶機(jī)端 ? import .*。 ? import .*。 ? class C ? { ? public static void main(String[] args) ? { ? try{ ? Socket socket=new Socket(,6565)。 ? DataOutputStream out=new DataOutputStream(())。 ? (我是客戶機(jī) )。 ? DataInputStream in=new DataInputStream(())。 ? String s=()。 ? (客戶機(jī)收到: +s)。 ? }catch(Exception e){} ? } ? } 36 服務(wù)器端 ? import .*。 ? import .*。 ? class S ? { ? public static void main(String[] args) ? { ? try{ ? ServerSocket s_socket=new ServerSocket(6565)。 ? Socket socket=()。 ? DataInputStream in=new DataInputStream(())。 ? String s=()。 ? (服務(wù)器收到: +s)。 ? DataOutputStream out=new DataOutputStream(())。 ? (我是服務(wù)器 )。 ? }catch(Exception e){} ? } ? } 37 Socket ? 顯示服務(wù)器與客戶機(jī)間的通信 (服務(wù)器端 ) DataOutputStream out=null。 DataInputStream in=null。 ServerSocket s_socket=null。 Socket c_socket=null。 String s。 //存放讀取到的信息 try { s_socket=new ServerSocket(4331)。 }catch (IOException e){ } try { c_socket=()。 …… }catch (IOException e){ } 創(chuàng)建服務(wù)器 (端口號(hào) ) 定義數(shù)據(jù)成員 服務(wù)器等待 網(wǎng)絡(luò)連接 用循環(huán)語(yǔ)句收發(fā)信息 (見下頁(yè) ) 38 in=new DataInPutStream(())。 out=new DataOutputStream(())。 創(chuàng)建服務(wù)器 (端口號(hào) ) 定義數(shù)據(jù)成員 服務(wù)器等待 網(wǎng)絡(luò)連接 建立 socket流 等待客戶登錄 (“這里是服務(wù)器 )。 ()。 While (true) { s=( )。 if ( s!=null ) break。 } 讀客戶 端信息 39 創(chuàng)建 Sock
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1