socket = new Socket("127.0.0.1", 8025);
dis = new DataInputStream(socket.getInputStream());
dos = new DataOutputStream(socket.getOutputStream());
new Thread(new ClientThread(this)).start();
}
public Socket getSocket() {
return socket;
}
public void setSocket(Socket socket) {
this.socket = socket;
}
public DataOutputStream getDos() {
return dos;
}
public void setDos(DataOutputStream dos) {
this.dos = dos;
}
public DataInputStream getDis() {
return dis;
}
public void setDis(DataInputStream dis) {
this.dis = dis;
}
public void close() {
try {
dis.close();
dos.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void sendMessage(String message) {
try {
dos.writeUTF(message);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Client client = null;
try {
client = new Client();
System.out.println(client.getSocket().getLocalPort());
} catch (IOException e) {
System.out.println("BUG");
e.printStackTrace();
System.exit(-1);
}
String message = "";
Scanner scanner = new Scanner(System.in);
while (!message.equals("logout")) {
message = scanner.nextLine();
// System.out.println(message);
client.sendMessage(message);
}
scanner.close();
client.close();
}
}
class ClientThread implements Runnable {
private Client client;
public ClientThread(Client client) {
super();
this.client = client;
}
@Override
public void run() {
try {
while (true) {
System.out.println(client.getDis().readUTF());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
iOS应用跳转QQ(QQ群)聊天界面项目中涉及到需要跳转到QQ聊天界面,所以查了腾讯的文档,但是没有找到网上所说的地址: mqq://im/chat?chat_type=wpauin=%@version=1src_type=web ,
只在 qun.qq.com 找到了跳转QQ群的地址: mqqapi://card/show_pslcard?src_type=internalversion=1uin=%@key=%@card_type=groupsource=external。希望了解的人指点一下
用java实现QQ群聊很久前写的代码了跳转qq群java代码,以前能运行 。电脑没装jdk跳转qq群java代码,没试试,自己试一下把 。。
---------------服务器------------
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
class myframe extends Frame implements ActionListener,WindowListener,Runnable,KeyListener
{
Thread mythread = new Thread(this);
Socket mysocket;
DataInputStream in;
DataOutputStream out;
Label label_ip = new Label("IP");
Label label_port = new Label("Port");
TextField text_ip = new TextField("127.1.1.0",15);
TextField text_port = new TextField("8888",15);
Button button_connect = new Button("连接");
TextArea text_area_show = new TextArea();
TextField text_send = new TextField(45);
Button button_send = new Button("发送");
myframe()
{
Panel panel1 = new Panel();
Panel panel2 = new Panel();
panel1.setLayout(new FlowLayout());
panel1.add(label_ip);
panel1.add(text_ip);
panel1.add(label_port);
panel1.add(text_port);
panel1.add(button_connect);
panel2.setLayout(new FlowLayout());
panel2.add(text_send);
panel2.add(button_send);
add(panel1,BorderLayout.NORTH);
add(text_area_show,BorderLayout.CENTER);
add(panel2,BorderLayout.SOUTH);
text_send.addKeyListener(this);
button_connect.addActionListener(this);
推荐阅读
- 手机福利直播软件,手机福利直播软件有哪些
- c语言中怎么弄输出的宽度,c语言数据输出长度超过指定宽度
- 会务公司小程序怎么做,会务公司小程序怎么做推广
- mysql是怎么避免脏读 mysql怎么避免回表
- 我的迷你世界下载,我的迷你世界下载安装免费
- oracle取小的函数,oracle获取小数点后的数值
- 圣岛服务器,圣岛入口在哪里
- go语言函数与接口 go语言接口做参数
- mysql修改数据的语句,mysql修改语句汇总