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

正文內(nèi)容

論文-090-基于java網(wǎng)絡(luò)技術(shù)實現(xiàn)網(wǎng)絡(luò)聊天室-資料下載頁

2024-11-07 20:34本頁面

【導(dǎo)讀】基于Java網(wǎng)絡(luò)技術(shù)實現(xiàn)網(wǎng)絡(luò)聊天室

  

【正文】 plait distance that realizes with the project the chat to proceed the discussion with the pack to the Java a project has the customer usage more simple, the interface even keeps view etc. characteristics. Keywords: Network plait distance, Client/ Server, Agreement,Java,Chat room 附錄一、服務(wù)器程序代碼 //聊天室服務(wù)器程序; import .*。 import .*。 import .*。 import .*。 import .*。 //服務(wù)器主類 public class ServerFrame extends Frame implements Runnable,ActionListener { int PORT=8000。 //定義端口號; protected ServerSocket listen。 //定義服務(wù)器端對象 listen監(jiān)聽服務(wù)//器,用來接收客戶端的請求; static Vector Clients。 //向量類存放與服務(wù)器連接的客戶線程列表; Thread serverthread。 //定義服務(wù)器端線程; 17 TextArea ServerStatus。 //定義服務(wù)器窗口文本域; Button CloseServer。 //關(guān)閉服務(wù)器按鈕; public static void main(String args[]) { new ServerFrame()。 } public ServerFrame() //服務(wù)器窗口構(gòu)造函數(shù); { super(服務(wù)器 )。 CloseServer = new Button(關(guān)閉服務(wù)器 )。 //建立關(guān)閉服務(wù)器按鈕; ServerStatus = new TextArea()。 //建立 文本域?qū)嵗?,在其中顯示時時狀態(tài); (false)。 //不能編輯文本域; (this)。 //注冊關(guān)閉按鈕事件處理方法; setLayout(new BorderLayout())。 //設(shè)置布局; add(Center,ServerStatus)。 add(South,CloseServer)。 setSize(400,400)。 //設(shè)置寬度與高度; setResizable(false)。 //設(shè)置不可改變窗口大?。? (.......................... 服 務(wù) 器 已 啟動 ..........................\n\n)。 ( 等 待 客 戶 聯(lián) 機\n\n)。 show()。 //顯示窗口; try { listen=new ServerSocket(PORT)。 //創(chuàng)建使用本地 IP地址創(chuàng)建一個服務(wù)//器,即在計算機的指定端口處建立監(jiān)聽服務(wù)器 ,創(chuàng)建過程中可能出現(xiàn) IO錯誤; } catch(IOException e) //捕捉輸入輸出( IO)錯誤; { (ERRO:+e)。 //輸出錯誤流; (0)。 //終止當(dāng)前運行的 java虛擬機; } Clients=new Vector(1000)。 //創(chuàng)建向量類實例,參數(shù)為客戶線程列表的數(shù)目; serverthread=new Thread(this)。 //創(chuàng)建服務(wù)器新線程實例; ()。 //啟動服務(wù)器端新線程; } //實現(xiàn)接口; 18 public void actionPerformed(ActionEvent e) //當(dāng)按下關(guān)閉按鈕時; { dispose()。 //Frame 繼承了 Window的方法; (0)。 //關(guān)閉窗口; } public void run() //服務(wù)器端的 serverthread線程操作 run方法; { try { while(true) //循環(huán)始終監(jiān)聽來自網(wǎng)絡(luò)端口的信息; { Socket ConnectSocket=()。 //接受來自 Client端的請求,//此時等待聯(lián)機;此時可能在等待的過程中會產(chǎn)生 IO錯誤; //為每一個人分別啟動一個客戶端線程 ,連接一個客戶啟動一個; ClientThread personal=new ClientThread(this,ConnectSocket)。 //創(chuàng)建客戶線程實例; ()。 //調(diào)用線程 Thread類方法來修改系統(tǒng)設(shè)定的線程優(yōu)先級; ()。 //客戶端線程啟動; (personal)。 //將客戶端線程加入向量列表 中; } } catch(IOException e) //處理 IO錯誤; { (Erro:+e)。 //打印出錯誤信息流; (0)。 } } //向聊天室所有人員發(fā)送普通話語信息; public void broadcast(String message) { for(int i=0。i()。i++) { ClientThread personal=(ClientThread)(i)。 try { (message)。 //發(fā)送給客戶端信息; 19 } catch(IOException e) { } } } //處理悄悄話,向特定人員發(fā)送悄悄話; public void broadcastprivy(String message) { int i。 String s1,s2,s3。 ClientThread personal 。 s1=new String(PEOPLE)。 s2=new String((4))。 s3=(s2)。 for(i=0。i()。i++) { personal=(ClientThread)(i)。 if(()) //name格式為: PEOPLE+名字 +[性別 ]。 { try { (message)。 } catch(IOException e) { } } } } } //客戶端線程類 //服務(wù)器為每一個客戶端啟動的線程; class ClientThread extends Thread { protected Socket ConnectSocket。 String line,name。 //line讀取來自 客戶端的消息; name格式為 : PEOPLE+名字 +[性別 ]。 protected ServerFrame server。 protected DataOutputStream firstout,out。 //定義網(wǎng)絡(luò)數(shù)據(jù)輸出流; protected DataInputStream in。 //定義網(wǎng)絡(luò)數(shù)據(jù)輸入流; //firstthread初始化線程; 20 public ClientThread(ServerFrame server,Socket ConnectSocket) { =server。 =ConnectSocket。 try { in =new DataInputStream(())。 out=new DataOutputStream(())。 firstout=new DataOutputStream(())。 } catch(IOException e) //捕捉輸入輸出錯誤異常; { try { (this)。 //若連接不上則刪除向量序列中第一個與指定的參數(shù)對象相同的元素,同時后面的補上; ()。 } catch(IOException e2) { (刪除過程中出現(xiàn)了錯誤! +e)。 //打印出輸入//輸出的錯誤信息; return。 } } } public void run() //運行客戶端線程; { try { //客戶端線程初始化運行讀取服務(wù)器端的已有聊天室人員列表信息; for(int i=0。i()。i++) { ClientThread per=(ClientThread)((i))。 //從向量中取出一個元素轉(zhuǎn)換成客戶線程,以便使用; if(!=null) //如果名字不為空; { try 21 { (+*)。 //輸出“ PEOPLE” +名//字 +“ *”到客戶端; } catch(IOException e) { } } } } catch(ArrayIndexOutOfBoundsException e){ } catch(NullPointerException e) {} //客戶端線程始終在監(jiān)聽的操作方法; try { while(true) { line=()。 //line讀取來自客戶端線路的信息; //線路信息前端為 PEOPLE表明有新人進入了聊天室; if((PEOPLE)) //如果客戶端輸入了姓名按下“進//入聊天室”按鈕后字符串前綴為“ PEOPLE”; { try { //獲取當(dāng)前對象的線程; ClientThread client=(ClientThread)(((this)))。 //搜索是哪個客戶端線程發(fā)送的消息; if(==null) //如果名字 為空; =line。 //有人在一個窗口中換用另一個名字登陸; else if(!=null) //如果名字不為空; { (QUIT+)。 //使原來的人離開 =line。 } } catch(ArrayIndexOutOfBoundsException e) { } catch(NullPointerException e){ } finally 22 { (line)。 } //向聊天室所有人員發(fā)送有人進入聊天室信息; } //線路信息前端為 QUIT表明有人離開了聊天室; else if((QUIT)) { (QUIT+)。 (this)。 //退出一個向量線程;; ()。
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1