Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » 编程/算法/API  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 看下这个程序哪有错误?(非法字符 \12288)
乱owen





发贴: 19
积分: 0
于 2006-11-14 20:33 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

import java.net.*;
import java.io.*;
import java.lang.*;

public class myserver{
public static void main(String args[]){
ServerSocket server;
Socket socket;
String s;
InputStream Is;
OutputStream Os;
DataInputStream DIS;
PrintStream PS;

try{
//在端口4321注册服务
server=new ServerSocket(4321);
socket=server.accept();   //监听窗口,等待连接

System.out.println("server ok");
System.out.println("************************************************");
System.out.println("");

//获得对应Socket的输入/输出流
Is=socket.getInputStream();
Os=socket.getOutputStream();
//建立数据流
DIS=new DataInputStream(Is);
PS=new PrintStream(Os);
DataInputStream in=new DataInputStream(System.in);
while(true){
System.out.println("");
System.out.println("please wait client's message...");
System.out.println("");
s=DIS.readLine(); //读入从client传来的字符串
System.out.println("client said:"+s); //打印字符串
if(s.trim().equals("BYE"))break; //如果是"BYE",就退出
System.out.print("you say:");
s=in.readLine(); //读取用户输入的字符串
PS.println(s); //将读取得字符串传给client
if(s.trim().equals("BYE"))break; //如果是"BYE",就退出

}

//关闭连接
DIS.close(); //关闭数据输入流
PS.close(); //关闭数据输出流
Is.close(); //关闭输入流
Os.close(); //关闭输出流
socket.close(); //关闭sockey
}
catch(Exception e){
System.out.println("Error:"+e);
}
}
}



why edited on 2006-11-15 08:41


话题树型展开
人气 标题 作者 字数 发贴时间
19177 看下这个程序哪有错误?(非法字符 \12288) 乱owen 1338 2006-11-14 20:33
14368 Re:看下这个程序哪有错误? q_yuan 40 2006-11-14 23:29
14317 Re:看下这个程序哪有错误? 乱owen 24 2006-11-15 04:15
14283 Re:看下这个程序哪有错误? scottlai 8 2006-11-15 07:38
10312 Re:看下这个程序哪有错误? xubingzhen 12 2008-11-03 13:16
11471 Re:看下这个程序哪有错误?(非法字符 \12288) JiafanZhou 532 2008-11-10 18:04

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923