初学者,被客户端和服务器搞得掉了10斤头发,救救孩子



//这里是服务器

package 封装版Chat;


import java.io.DataInputStream;

import java.io.DataOutputStream;

import java.io.IOException;

import java.net.ServerSocket;

import java.net.Socket;


@SuppressWarnings("all")

public class Mult_Chat3_0 {

public static void main(String[] args) throws Exception {

System.out.println("服务器启动中。。。。");

ServerSocket server = new ServerSocket(8888);

System.out.println("服务器已启动");

while (true) {

Socket cilent = server.accept();

System.out.println( "1个客户端建立了连接");

new Thread(new Channel(cilent)).start();

}

}


//一个客户一个Channel

static class Channel implements Runnable {

private DataInputStream dis;

private DataOutputStream dos;

private Socket client;

private boolean isRunnning;


public Channel(Socket client) {

this.client = client;

try {

dis = new DataInputStream(client.getInputStream());

dos = new DataOutputStream(client.getOutputStream());

isRunnning = true;

} catch (IOException e) {

//e.printStackTrace();

System.out.println("-----1-----");

release();//只要出错就关流

}

}


//接收消息

private String recieve() {

String msg = "";//这样的好处是不会有空指针异常

try {

msg = dis.readUTF();

}catch (IOException e) {

System.err.println("----3服务器接收------"+e.getCause());

release();

}

return msg;

}



//发送消息

private void send(String msg) {


try {

dos.writeUTF(msg);

dos.flush();

} catch (IOException e) {

System.out.println("----1发送出问题------");

release();

}


}


//释放资源

private void release() {

this.isRunnning = false;

Util.close(dis, dos, client);

}


@Override

public void run() {

while (isRunnning) {

String msg = recieve();

if (!msg.equals("")) {

System.out.println(msg);

send(msg);

}

}

}

}

}




//这里是客户端

package 封装版Chat;


import java.io.*;

import java.net.Socket;

import java.util.Scanner;


public class Mult_Client3_0_1 {

public static void main(String[] args) throws IOException {

System.out.println("客户端01正在启动");

Socket client = new Socket("localhost",8888);

System.out.println("01已启动");

//2.客户端发送消息

new Thread(new Send(client)).start();

//客户端接收消息

new Thread(new Recieve(client)).start();

}

}


//这里是

//封装Send的Runnable实现类

package 封装版Chat;


import java.io.*;

import java.net.Socket;

/*封装好Send线程实现类可以让发和收同步*/

/*

* 1.声明

* 2.构造方法

* 3.从控制台接收数据

* 4.发消息

* 5.跑

* */


public class Send implements Runnable {


//1.

private BufferedReader console;

private DataOutputStream dos;

private Socket client;

private boolean isRunnning;


//2.

public Send(Socket client) {

this.client = client;

try {

dos = new DataOutputStream(client.getOutputStream());

} catch (IOException e) {

System.out.println("-----Send类构造-----"+e.getMessage());

release();

}

}


//3.

private String getMessageFromConsole() {

System.out.println("请输入");

console = new BufferedReader(new InputStreamReader(System.in));

try {

return console.readLine();

} catch (IOException e) {

System.out.println("----Send类getMessageFromConsole()异常");

}

return "";

}


//4.

private void send(String msg) {

try {

dos.writeUTF(msg);

dos.flush();

} catch (Exception e) {

System.out.println("----Send类send方法------"+e.getMessage());

release();

}


}


//5.

@Override

public void run() {

while (isRunnning) {

String msg = getMessageFromConsole();

if (!msg.equals("")&&!msg.equals(null)) {

send(msg);

}


}


}




//释放资源

private void release() {

this.isRunnning = false;

Util.close(dos, client);

}


}


//这里是封装Recieve的Runnable实现类

package 封装版Chat;


import java.io.DataInputStream;

import java.io.IOException;

import java.net.Socket;


//1./*

//* 1.声明

//* 2.构造方法

//* 3.收消息

//* 4.跑

//* */


public class Recieve implements Runnable{

//1.

private DataInputStream dis;

private Socket client;

private boolean isRunnning;


//2.

public Recieve(Socket client){

this.client = client;

try {

dis = new DataInputStream(client.getInputStream());

}catch (Exception e){

System.out.println("-----2Recieve-------");

this.release();

}

}


//3.

private String recieve() {

String msg = "";

try {

msg = dis.readUTF();

} catch (IOException e) {

System.out.println("----3recieve------");

release();

}

return msg;

}


//4.

@Override

public void run() {

while (isRunnning){

String msg = recieve();

if(!msg.equals("")){

System.out.println(msg);

}

}


}



//释放资源

private void release() {

this.isRunnning = false;

Util.close(dis, client);

}

}

...

# [博主推荐]如何利用注册 的 bug 来疯狂注册,不停开小号"做"事情[你懂的],支持 手机号&邮箱 ,非常简单


# 具体见 [链接](https://www.cnblogs.com/deeplight/p/gogogo.html)

(https://www.cnblogs.com/deeplight/p/gogogo.html)


摘要:

### 使用场景:

>>> 每一个号都会送一些福利或有一定的功能,多开可叠加~


>>> 可以互相作用,比如用另外的几十个号一起点赞,称好,或发同样内容,提高曝光率


>>> 当你的号违反网站规矩(比如在人家的地盘说人家坏话,或跟其竞争,博客首页就有反CSDN的),开好几个号,客服有封你冻你的功夫你都开好几个了(1~2min就能开一个)


>>> 还可以让客服感受到你的恐怖,因为我本身没什么不一样(注册时),对吧


 所以,客服在无奈解冻我3次后,再也不怼我了


方法简介(详细见链接)

1.在免费接验证码平台收码

2.用outlook直接开邮箱

3.清除cookies再来


[本文链接](https://www.cnblogs.com/deeplight/p/gogogo.html)

https://blog.csdn.net/w_linux/article/details/79394150
这里有现成的.