|
udp写的局域网聊天系统,基于IP地址带界面gui-『编程语言区』-吾爱破解-LCG-LSG|安卓破解|病毒分析|破解软件|www.52pojie.cn{"@context":"https://ziyuan.baidu.com/contexts/cambrian.jsonld","@id":"https://www.52pojie.cn/thread-759831-1-1.html","appid":"1576031629188970","title":"udp写的局域网聊天系统,基于IP地址带界面gui","images":[],"description":"[Java]纯文本查看复制代码importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjava.net.*;import","pubDate":"2018-07-01T11:51:45"}官方微博违规会员处罚记录官方入门教学培训_New开启辅助访问【验证码异常^等待验证会员^冻结用户】【清理未活跃会员】【网络诊断修复工具】切换到窄版请登录后使用快捷导航没有帐号?注册[Register]帐号自动登录找回密码密码登录注册[Register]只需一步,快速开始安全验证#xe60c;请完成以下验证码快捷导航门户Portal网站www新帖论坛最新帖子一览无余!搜索由百度提供的站内搜索,优点搜索内容全而快。专辑Collection悬赏吾爱破解论坛帮助大家解决问题,共同进步,获取论坛币!排行榜Ranklist总版规爱盘在线破解工具包,实时提供最新逆向资源! 关注人的新帖技术新帖合集原创发布新贴脱壳破解新帖移动安全新帖病毒分析新帖软件调试新贴动画发布新帖邀请好友注册LCGLSGTools吾爱破解Logo吾爱破解桌面壁纸吾爱破解视频教程吾爱破解论坛精华集吾爱破解专用版Ollydbg处理举报贴处理福利贴处理水区贴办公区证据区论坛邮箱原创发布区精品软件区逆向资源区水漫金山区影视推荐区福利经验区脱壳破解区移动安全区病毒分析区编程语言区动画发布区安全工具区站点公告站点导航站点总版规申请专区招聘求职违规怎么办站点帮助站务处理搜索搜索热搜:新手脱壳内购ctf去广告破解版绿色版破解教程本版用户@importurl('https://avatar.52pojie.cn/mw_syntaxhighlighter/syntaxhighlighter3/styles/shCore.css?ver=3.0.83');@importurl('https://avatar.52pojie.cn/mw_syntaxhighlighter/syntaxhighlighter3/styles/shCoreRDark.css?ver=3.0.83');@importurl('https://avatar.52pojie.cn/mw_syntaxhighlighter/syntaxhighlighter3/styles/shThemeRDark.css?ver=3.0.83');.syntaxhighlighter,.syntaxhighlightera,.syntaxhighlighterdiv,.syntaxhighlightercode,.syntaxhighlightertable,.syntaxhighlightertabletd,.syntaxhighlightertabletr,.syntaxhighlightertabletbody,.syntaxhighlightertablethead,.syntaxhighlightertablecaption,.syntaxhighlightertextarea{font-size:14px!important;/*Setthefontsizeinpixels*/font-family:"Consolas","BitstreamVeraSansMono","CourierNew",Courier,monospace!important;/*Setthefonttype*/}.syntaxhighlightertablecaption{/*ForTitle(Caption)*/font-size:14px!important;/*Setthefontsizeinpixels*/font-family:"Consolas","BitstreamVeraSansMono","CourierNew",Courier,monospace!important;/*Setthefonttype*/}.syntaxhighlighter.noguttertd.code.line{/*Settheleftpaddingspacewhenno-gutterinver.3.0*/padding-left:3px!important;}.syntaxhighlighter.lines{ padding:5px0px5px0px!important;}.syntaxhighlighter.line.number{ padding:5px5px5px0!important;}.syntaxhighlighter.line.content{ padding:5px0px5px10px!important;}/*Forgutter*/.syntaxhighlightertabletd.code{width:auto!important;}.syntaxhighlightertabletd.gutter.line{padding:00.5em!important;}.syntaxhighlighter.gutter{width:40px!important;}.syntaxhighlightertabletd.gutter.line{ padding:5px5px5px0!important;}.syntaxhighlightertabletd.code.line{ padding:5px0px5px10px!important;}.syntaxhighlighter{/*ForChrome/Safari(WebKit)*//*Hidethesuperfluousverticalscrollbarinver.3.0*//*overflow-y:hidden!important;*/padding:1px!important;}.syntaxhighlighter{ width:99.7%!important; overflow-y:auto;}/*ForTitle(Caption)*/font-size:10px!important;/*Setthefontsizeinpixels*/font-family:"Consolas","BitstreamVeraSansMono","CourierNew",Courier,monospace!important;/*Setthefonttype*/}安全验证#xe60c;请完成以下验证码吾爱破解-LCG-LSG|安卓破解|病毒分析|破解软件|www.52pojie.cnraquo;网站rsaquo;【软件安全】rsaquo;『编程语言区』rsaquo;udp写的局域网聊天系统,基于IP地址带界面gui返回列表查看:403|回复:6[Java]udp写的局域网聊天系统,基于IP地址带界面gui[复制链接]公子语凉公子语凉当前离线好友记录日志相册分享阅读权限10听众收听狗仔卡电梯直达楼主发表于2018-7-111:51|只看该作者|倒序浏览本板块禁止发布“电子书资料”,此类主题请发布至『电子书屋』。本板块禁止发布讨论和求助帖,此类主题请发布至『编程语言讨论求助区』。本板块禁止发布“视频教程”,此类主题请发布至『动画精品转载区』。.pcb{margin-right:0}分享到:QQ好友QQ空间微信新浪微博豆瓣网邮件分享[Java]纯文本查看复制代码importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjava.net.*;importjava.util.*;importjavax.swing.*;publicclassTest01{ publicstaticvoidmain(String[]args) { myFramemy=newmyFrame(quot;setvisiblequot;); }}classmyFrameextendsJFrame{ JTextAreashow,input; JTextFieldhost,sendpoint,receivepoint; JButtonsure,send,filesend; publicmyFrame(Stringstr) { super(str); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setBounds(200,200,470,570); this.setLayout(newFlowLayout()); this.setResizable(false); init(); this.setVisible(true); } publicvoidinit() { show=newJTextArea(10,40); show.setLineWrap(true); show.setEditable(false); add(newJScrollPane(show)); add(newJLabel(quot;****目的ip地址:****quot;)); host=newJTextField(30); add(host); add(newJLabel(quot;*****目的端口:*****quot;)); sendpoint=newJTextField(30); add(sendpoint); add(newJLabel(quot;*****接收端口:*****quot;)); receivepoint=newJTextField(30); add(receivepoint); sure=newJButton(quot;确认端口设置quot;); add(sure); sure.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { Stringpoint=receivepoint.getText(); if(point==null) { return; } receiver=newreceive(point); newThread(r).start(); receiveFilerf=newreceiveFile(); newThread(rf).start(); } }); JButtonsave=newJButton(quot;保存聊天记录quot;); add(save); save.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { JFileChooserjfc=newJFileChooser(quot;D:quot;); Stringstr=show.getText(); jfc.showSaveDialog(save); Filef=jfc.getSelectedFile(); if(f==null) { return; } try { FileOutputStreamout=newFileOutputStream(f); out.write(str.getBytes(),0,str.getBytes().length); out.close(); }catch(IOExceptione1){} } }); JButtonclear=newJButton(quot;清屏quot;); add(clear); clear.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { show.setText(quot;quot;); } }); input=newJTextArea(10,40); show.setLineWrap(true); add(newJScrollPane(input)); input.addKeyListener(newKeyAdapter() { publicvoidkeyPressed(KeyEvente) { if(e.getKeyCode()==KeyEvent.VK_ENTER) { Stringip=host.getText(); Stringpoint=sendpoint.getText(); Stringmessage=input.getText(); sends=newsend(ip,point,message); newThread(s).start(); input.setText(quot;quot;); } } }); send=newJButton(quot;发送quot;); add(send); send.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { Stringip=host.getText(); Stringpoint=sendpoint.getText(); Stringmessage=input.getText(); if(ip==nullpoint==nullmessage==null) { return; } sends=newsend(ip,point,message); newThread(s).start(); input.setText(quot;quot;); } }); filesend=newJButton(quot;发送文件quot;); add(filesend); filesend.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { JFileChooserjfc=newJFileChooser(quot;D:quot;); jfc.showOpenDialog(filesend); Stringip=host.getText(); Filef=jfc.getSelectedFile(); sendFilesf=newsendFile(ip,f); newThread(sf).start(); } }); JButtonreset=newJButton(quot;重置quot;); add(reset); reset.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { input.setText(quot;quot;); } }); JButtonquit=newJButton(quot;退出quot;); add(quit); quit.addActionListener(newActionListener() { publicvoidactionPerformed(ActionEvente) { System.exit(0); } }); } classreceiveimplementsRunnable { intpoint; receive(Stringreceivepoint) { this.point=Integer.parseInt(receivepoint); } publicvoidrun() { DatagramSocketds=null; DatagramPacketdp=null; byte[]buf=newbyte[8848]; try { ds=newDatagramSocket(point); dp=newDatagramPacket(buf,buf.length); }catch(Exceptione){} while(true) { if(ds==null) { break; }else { try { ds.receive(dp); Stringmessage=newString(buf,0,dp.getLength()); Stringip=dp.getAddress().getHostAddress(); show.append(newDate().toLocaleString() +quot;\nquot; +ip +quot;已接收:quot; +quot;\tquot; +message +quot;\nquot; ); }catch(IOExceptione) {} } } } } classreceiveFileimplementsRunnable { publicvoidrun() { DatagramSocketds=null; DatagramSocketds1=null; DatagramPacketdp=null; DatagramPacketdp1=null; FileOutputStreamout=null; byte[]buf=newbyte[88488]; byte[]buf2=newbyte[100]; try { ds=newDatagramSocket(9999); ds1=newDatagramSocket(10000); dp=newDatagramPacket(buf,buf.length); dp1=newDatagramPacket(buf2,buf2.length); }catch(Exceptione){} while(true) { if(ds==null) { break; }else { try { ds1.receive(dp1); Stringfilename=newString(buf2,0,dp1.getLength()); Filef=newFile(filename); f.createNewFile(); ds.receive(dp); out=newFileOutputStream(f); out.write(buf,0,dp.getLength()); Stringip=dp.getAddress().getHostAddress(); show.append(newDate().toLocaleString() +quot;\nquot; +quot;已接收来自:quot; +ip +quot;的文件quot; +quot;\nquot; ); }catch(IOExceptione){} } } } } classsendimplementsRunnable { Stringhost; intsendpoint; Stringmessage; send(Stringhost,Stringsendpoint,Stringmessage) { this.host=host; this.sendpoint=Integer.parseInt(sendpoint); this.message=message; } publicvoidrun() { try { InetAddressip=InetAddress.getByName(host); DatagramSocketds=newDatagramSocket(); DatagramPacketdp=newDatagramPacket(message.getBytes(),message.getBytes().length,ip,sendpoint); ds.send(dp); show.append(newDate().toLocaleString() +quot;\nquot; +quot;已发送:quot; +quot;\tquot; +message +quot;\nquot; ); }catch(IOExceptione){} } } classsendFileimplementsRunnable { Stringhost; Filef; sendFile(Stringhost,Filef) { this.host=host; this.f=f; } publicvoidrun() { try { InetAddressip=InetAddress.getByName(host); byte[]fn=f.getName().getBytes(); DatagramSocketfilename=newDatagramSocket(); DatagramPacketdp=newDatagramPacket(fn,fn.length,ip,10000); filename.send(dp); FileInputStreamin=newFileInputStream(f); byte[]buf=newbyte[in.available()]; DatagramSocketds=newDatagramSocket(); DatagramPacketdp1=newDatagramPacket(buf,buf.length,ip,9999); in.read(buf); ds.send(dp1); show.append(newDate().toLocaleString() +quot;\nquot; +quot;已成功发送一个文件quot; +quot;\nquot; ); }catch(IOExceptione){} } }}代码中的异常我没有去处理,你们如果有兴趣可以二次修改.做这个的目的是帮助室友Java考试的......现在考试结束了,分享出来,让大家指点一下...
|
上一篇: 最近很火的表白网站源码,上传即可使用下一篇: weather pro(已付费)
|