教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

《计算机网络通信》课程设计报告(7)

来源:网络收集 时间:2026-08-26
导读: 附 录 } public void sendStopToAll()//向所有在线用户发送服务关闭消息 { int count =userInfoList.getCount(); int i=0; while (i Node node=userInfoList.find(i); if(node==null) { } try - 18 - i++; contin

附 录

}

public void sendStopToAll()//向所有在线用户发送服务关闭消息 {

int count =userInfoList.getCount(); int i=0; while (i

Node node=userInfoList.find(i); if(node==null) { } try

- 18 -

i++; continue;

int i=0; while (i

jbStartServer.setEnabled(true); jbStopServer.setEnabled(false); systemMsg.setEnabled(false);

Node node=userInfoList.find(i);

node.input.close(); node.output.close(); node.socket.close(); i++;

combobox.removeAllItems(); combobox.addItem(\所有人\}

catch(Exception e) { }

附 录

}

public void sendSystemMessage()//实现发送系统消息功能 { }

- 19 -

String toSomebody=combobox.getSelectedItem().toString(); String message=systemMsg.getText(); if (toSomebody.equalsIgnoreCase(\所有人\{ } else { }

Node node=userInfoList.find(toSomebody); try { }

catch (Exception e) { }

node.output.writeObject(\系统信息\node.output.flush();

node.output.writeObject(message+\node.output.flush();

sendMsgToAll(message+\ }

{ }

catch(Exception e) { } i++;

node.output.writeObject(\服务关闭\node.output.flush();

附 录

public void sendMsgToAll(String msg) { } }

//服务器侦听线程类 import java.awt.*;

- 20 -

public static void main(String args[]) { }

new ServerFrame();

int count=userInfoList.getCount(); int i=0; while (i

Node node=userInfoList.find(i); if (node==null) { } try { }

catch (Exception e) { } i++;

node.output.writeObject(\系统信息\node.output.flush();

node.output.writeObject(msg); node.output.flush(); i++; continue;

附 录

import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.io.*; import java.net.*;

public class ServerListenThread extends Thread {

ServerSocket server;

JComboBox combobox; JTextArea textarea; JTextField textfield; UserInfoList userInfoList;

Node client;

ServerReceiveThread recvThread;

public boolean isStop;

public ServerListenThread( { }

- 21 -

this.server=server; this.combobox=combobox; this.textarea=textarea; this.textfield=textfield; this.userInfoList=userInfoList; isStop=false;

ServerSocket server, JComboBox combobox, JTextArea textarea, JTextField textfield, UserInfoList userInfoList )

附 录

public void run() {

while (!isStop&&!server.isClosed()) {

try {

client=new Node();

client.socket=server.accept(); client.output=new

ObjectOutputStream(client.socket.getOutputStream());

client.output.flush(); client.input=new

ObjectInputStream(client.socket.getInputStream());

}

}

}

}

catch(Exception e) { }

client.username=(String)client.input.readObject();

combobox.addItem(client.username); userInfoList.add(client);

textarea.append(\上线\

textfield.setText(\在线用户\人\\n\recvThread=new ServerReceiveThread(

textarea, textfield, combobox, client, userInfoList);

recvThread.start();

//服务器接收线程类

- 22 -

…… 此处隐藏:632字,全部文档内容请下载后查看。喜欢就下载吧 ……
《计算机网络通信》课程设计报告(7).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/519030.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)