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

正文內(nèi)容

基于cs模型的java聊天室_畢業(yè)設(shè)計-資料下載頁

2025-07-02 06:28本頁面

【導讀】開發(fā)網(wǎng)絡(luò)程序一樣,Java的網(wǎng)絡(luò)開發(fā)是相當方便的,通過Socket進行網(wǎng)絡(luò)信息傳輸。的基于網(wǎng)絡(luò)的服務(wù)和應(yīng)用程序。在網(wǎng)絡(luò)飛速發(fā)展的今天,各種各樣的的交流變的非常重要。限在小范圍內(nèi),人們渴望與其他國家或地區(qū)的人們進行交流。但由于地域的限制使人們。不可能在短時間內(nèi)得到面對面的交流。于是,人們不得不使用Inter這個可以把全世。界所有的人短時間內(nèi)都聯(lián)系到一起的新生事物,所以網(wǎng)上聊天室就誕生了。但隨著時間的發(fā)展和技術(shù)的提高,現(xiàn)在的聊。天室已經(jīng)具備強大的功能。例如,傳輸文件,語音聊天,視頻聊天等。足于言語上的交流,還可以分享彼此的珍藏的圖片,看到對方的面容。到了大家的一致好評。隨著手機可以上網(wǎng),手機也可以登錄到網(wǎng)上聊天室中,使人們不。僅僅局限于坐在電腦前聊天,可以隨時隨地的上網(wǎng)聊天。通過Socket的數(shù)據(jù)是原始字節(jié)。創(chuàng)建Socket,建立連接;按照一定的協(xié)議對Socket進行讀/寫操作;具,是目前使用最廣泛的Java開發(fā)工具之一。和具有不依賴于平臺性能的應(yīng)用程序。

  

【正文】 (str)。 } } public void run(){ try{ while(true){ for(int i=0。i()。i++){ Thread1=(CommunicateThread)(i)。 msgStack=。//得到每個連接的信息棧 ClientName=(String)(i)。//客戶名 //讀取每個連接線程的信息棧并把信息發(fā)送出去 for(int j=0。j()。j++){ string=(String)(j)。 broadcastInfor=ClientName++string。 broadcast(broadcastInfor)。 } //clear the inforStack ()。//清除以發(fā)送的信息 } try{ (100)。//version2 }catch(InterruptedException ex){} } }catch(Exception e){} } } //處理窗口關(guān)閉事件的適配器 class ChatFrame_WindowAdapter extends { 巢湖學院畢業(yè)設(shè)計(論文) 36 ChatRoomServer chatFrame。 public ChatFrame_WindowAdapter(ChatRoomServer chatFrame){ =chatFrame。 } public void windowClosing(WindowEvent e){//exit program ()。//reference to the method exit() in ChatRoomServer. } } import .*。 import .*。 import .*。 import .*。 public class ChatRoomClient extends Frame implements Runnable{ Panel panel1,panel2。 Button button1,button2。 TextField textField1,textField2。 Label label1。 TextArea textArea。 ScrollPane sPanel。 // PrintWriter out。 BufferedReader in=null。 Socket sock。 public final static int DEFAULT_PORT=6666。 //create Thread to Read information from Server Thread readThread。 boolean isTrue=true。//thread can go on runing ?? public ChatRoomClient(){ try{ jbInit()。 }catch(Exception e){ 巢湖學院畢業(yè)設(shè)計(論文) 37 ()。 } } public static void main(String[] args){//main method ChatRoomClient c=new ChatRoomClient()。 ()。 } private void jbInit(){//should set size,position and Font of every ponent button1=new Button(連接 )。// set Font button2=new Button(發(fā)送 )。 textField1=new TextField(input Server address here!)。 textField2=new TextField(input Message here and send to Server)。 label1=new Label(消息 :)。 panel1=new Panel()。 panel2=new Panel()。 sPanel=new ScrollPane()。 textArea=new TextArea()。 //panel1 //press button1: 連接 to connect the Client to Server (new (){ public void actionPerformed(ActionEvent e){ button1_actionPerformed(e)。 } })。 //textField1:for input the address of Server。be registered to KeyListener. //press key:Enter to connect the Client to Server (new textField1_KeyAdapter(this))。//() (button1)。 (textField1)。 //sPanel ScrollPane 巢湖學院畢業(yè)設(shè)計(論文) 38 (textArea)。 //panel2 //press button2: 發(fā)送 to send message (new (){ public void actionPerformed(ActionEvent e){ button2_actionPerformed(e)。 } })。 //textField2:for input message。be registered to KeyListener. //press key:Enter to send message (new textField2_KeyAdapter(this))。 (label1)。 (textField2)。 (button2)。 //frame (new ChatFrame_WindowAdapter(this))。//frame is registered to WindowListener (new BorderLayout())。 (500,400)。 (panel1,)。 (sPanel,)。 (panel2,)。 //() } public void startConnect(){//開始連接 try{ sock=new Socket((),DEFAULT_PORT)。 if(sock!=null){//connection successed processMsg(Connect successfully!)。 } in=new BufferedReader(new InputStreamReader(()))。 巢湖學院畢業(yè)設(shè)計(論文) 39 out=new PrintWriter(())。 }catch(IOException ex){ processMsg(())。 processMsg(Connect failed!)。 } readThread=new Thread(this)。 ()。 } //public void endConnect(){//close IOstream public void sendInformation(){ (())。 ()。 } private void button1_actionPerformed(ActionEvent e){//連接按鈕 startConnect()。 } private void button2_actionPerformed(ActionEvent e){//發(fā)送按鈕 sendInformation()。 } public void stopRun(){//to stop the running thread isTrue=false。 } public void processMsg(String msg){//客戶端處理消息 (msg)。 (\n)。 } public void run(){ String msg。 isTrue=true。 while(isTrue){ 巢湖學院畢業(yè)設(shè)計(論文) 40 try{ msg=()。 if((Server exit!)){//Server exit processMsg(msg)。 stopRun()。//終止線程 }else if(msg!=null){ processMsg(msg)。 } (1000)。 }catch(IOException e){ processMsg(())。 }catch(InterruptedException ei){ processMsg(())。 } } //endConnect()。 try{//服務(wù)器退出關(guān)閉連接和相關(guān)的 流 ()。 ()。 ()。 }catch(IOException ioe){} } public void exit(){//窗口關(guān)閉;如果有連接則關(guān)閉連接和相關(guān)的 流 try{//send Client exit! to Server! (Client exit!)。 ()。 }catch(Exception exc){} //endConnect()。 try{//close IOstream ()。 ()。 巢湖學院畢業(yè)設(shè)計(論文) 41 ()。 }catch(IOException ioe){} finally{ (0)。 } } } //文本筐 textField1 的鍵擊事件適配器 class textField1_KeyAdapter extends { ChatRoomClient chatFrame。 public textField1_KeyAdapter(ChatRoomClient chatFrame){ =chatFrame。 } public void keyPressed(KeyEvent e){//輸入的是 enter,開始連接! int j=()。 if(j==){ ()。 } } } //文本筐 textField2 的鍵擊事件適配器 class textField2_KeyAdapter extends { ChatRoomClient chatFrame。 public textField2_KeyAdapter(ChatRoomClient chatFrame){ =chatFrame。 } public void keyPressed(KeyEvent e){//鍵擊 Enter 鍵,發(fā)送信息! int j=()。 if(j==){ ()。 巢湖學院畢業(yè)設(shè)計(論文) 42 } } } //窗口關(guān)閉事件適配器 class ChatFrame_WindowAdapter extends { ChatRoomClient chatFrame。 public ChatFrame_WindowAdapter(ChatRoomClient chatFrame){ =chatFrame。 } public void windowClosing(WindowEvent e){//exit program ()。//reference to the method exit() in ChatRoomClient. } }巢湖學院畢業(yè)設(shè)計(論文) 43
點擊復制文檔內(nèi)容
研究報告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1