论坛首页 Java版 J2ME

如何用socket以及serversocket

浏览 149 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2008-04-16
要做一个短消息接受模块 运行程序需要测试用的发送短信 该类 如下写有什么问题
请各位帮帮忙 感激不尽 !!!!1


public class Client {
private Socket socket;

private BufferedReader in;

private PrintWriter print;

public Client() {
String message = null;
BufferedReader line = null;
try {
socket = new Socket("localhost", 10000);
in = new BufferedReader(new InputStreamReader(socket
.getInputStream()));
print = new PrintWriter(socket.getOutputStream());
while (true) {
System.out.println("请输入你要说的话");
line = new BufferedReader(new InputStreamReader(System.in));
message = line.readLine();
}
// print.write("");
// print.flush();
// line.close();
// in.close();
// print.close();
// socket.close();

} catch (UnknownHostException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}

public static void main(String [] args ){
Client client = new Client();

}
   
论坛首页 Java版 J2ME

跳转论坛:
JavaEye推荐
    快速回复 引用上一条消息 (Alt+S)