日期:2014-05-20 浏览次数:21147 次
package s;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class C_port {
Socket s = null;
OutputStream outputstream = null;
public C_port(){
try {
s = new Socket("127.0.0.1",60000);
outputstream = new DataOutputStream(s.getOutputStream());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String str = "CJ必胜!!CJCO!!CJHMF,这个问题解决了,我高兴了,现在我们的群里,加入了182个人\r\n我们群里的人,都决心互相学习,增长本领";
Lib.write(s, str);
}
public static void main(String[] args){
new C_port();
}
}
package s;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class S_port {
String str = "";
ServerSocket s =null;
Socket so = null;
S_port(){
try {
s = new ServerSocket(60000);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while(true){
try {
so = s.accept();
SystemThread m1 = new SystemThread(so);
m1.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args){
new S_port();
}
}
package s;
import java.io.DataInputStream;
import java.io.InputStream;
import java.net.Socket;
public class SystemThread extends Thread{
Socket so = null;
DataInputStream dips = null;
InputStream inputstream = null;
String str = null;
public SystemThread(Socket s){
so = s;
}
public void run(){
String str0 = Lib.readsocketUTF(so);
System.out.println(str0);
}
}
package s;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
public class Lib {
static InputStream is = null;
static OutputStream outputstream = null;
static String MyKey = "CJCO5882";
static PrintStream ps;
static BufferedReader br;
static String buffer0;
static OutputStream os = null;
static byte[] readbuf = null;
static byte[] writebuf = null;
static BufferedInputStream bis = null;
static BufferedOutputStream bos = null;
static int num = 0;
static String str = "";
static String readsocketUTF(Socket s){
String info = "";
try {
is = s.getInputStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
try {
str = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
info = Systemcrypt.HloveyRC4(str,MyKey);
return info;
}
static void write(Socket s,String str0){
System.out.println("接受到一个客户端消息:" + s);