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

正文內容

java語言程序設計(輸入輸出流、網(wǎng)絡通信)ppt(編輯修改稿)

2024-11-14 14:50 本頁面
 

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