|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
import java.io.*; import java.net.*; public class Wrnet { public static void main(String[] args) { byte[] buff = new byte[1024]; Socket wrsocket = null; InputStream instr = null; OutputStream outstr = null; boolean cont = true; try { wrsocket = new Socket(args[0], Integer.parseInt(args[1])); instr = wrsocket.getInputStream(); outstr = wrsocket.getOutputStream(); } catch (Exception e) { System.err.println("网络错误"); System.exit(1); } while (cont) { try { int n = System.in.read(buff); // System.out.write(buff, 0, n); if (buff[0] == ´#´) { cont = false; } else { outstr.write(buff, 0, n); } } catch (Exception e) { System.exit(1); } } cont = true; while (cont) { try { int n = instr.read(buff); System.out.write(buff, 0, n); } catch (Exception e) { cont = false; } } try { instr.close(); } catch (Exception e) { System.err.println("网络错误"); System.exit(1); } } } 返回类别: 教程 上一教程: JAVA基础知识(5) 下一教程: JAVABEAN在JSP中的应用 您可以阅读与"连接到网络服务器上并发送数据,随后接收服务器发送来的数据"相关的教程: · 接收网络服务器发送来的数据 · Java网络服务器编程(NIO版) · JAVA进阶学习:网络服务器编程 · Java网络服务器编程 · Java中通过代理服务器(proxy)访问网络 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |