public class ChatRoomServer {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(4800);
Socket s = ss.accept();
BufferedReader brs = new BufferedReader(new InputStreamReader(
System.in));
BufferedReader br = new BufferedReader(new InputStreamReader(
s.getInputStream()));
server端
package com.sina.www;
import java.net.*;
import java.io.*;
public class server {
public static void main(String[] args) throws Exception{
try {
ServerSocket s = new ServerSocket(8888);//创建端口号
Socket s1 = s.accept();//Socket接收
OutputStream os = s1.getOutputStream();//在服务器端导入输出流
DataOutputStream dos = new DataOutputStream(os);
InputStream is = s1.getInputStream();//在服务器端导入输入流
DataInputStream dis = new DataInputStream(is);
//InputStreamReader isr = new InputStreamReader(System.in);
//BufferedReader bf = new BufferedReader(isr);
new MyReaderServer (dis).start();//实例化MyReaderServer类并调用start()方法
new MyWriterServer(dos).start();//实例化MyWriterServer类并调用start()方法
System.out.println("在乎--主流:");//输出自己的网名