[求助]还想请大家帮帮忙
我不根本不知道线程和TCP/IP的Socket怎样连合起来一起用~我想做一个服务器来端创建对象SererSocket在某接口提供监听服务,下面是我自己乱写的一个,错得很离谱,请你们给个思路我吧!import javax.swing.*;
import java.awt.*;
import java.net.*;
import java.awt.event.*;
import java.io.*;
class MyServer1 extends Frame implements Runnable{
TextArea Meg=new TextArea(5,7);
String receiveMsg;
ServerSocket sSocket=null;
Socket csocket=null;
BufferedReader reade=null;
PrintStream writer=null;
Thread connectThread;
public void init(){
connectThread=new connectThread(this);
connectTread.start();
}
public void run(){
writer.println("Welcom connect to MyServer!\r");
writer.flush();
String s=reader.readLine();
while(!s.equals("Exit")){
receiveMsg.append("MyClient端输入的信息为:\n"+s);
cSocket.close();
dispose();
}
}
MyServer1(){
super("MyServer服务器端");
setSize(500,300);
setDefualtCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
add("Center",Meg);
setVisible(true);
}
public static void main(String args[]){
try{
sSocket=new ServerSocket(6000,10);
cSocket=sSocket.accept();
reader=new BufferedReader(new InputStreamReader(cSocket.getInputStream()));
writer=new PrintStream(cSocket.getOutputStream());
}catch(IOException e){}
MyServer ma=new MyServer();
}
}
我改了很多遍,上面可能都很乱,我也不会写!
大家给我个思路吧,也别批评我,我真的很无耐