package com.wenqier.send;

import java.io.PrintStream;
import java.net.Socket;

import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 * 发送客户端的消息
 * @author wenqier
 *
 */
public class SendMessage extends Thread {
	private String ip;
	private int i;
	Socket s = null;
	JLabel label = null;
	JTextField text;
	JTextArea text1;

	public SendMessage(String ip, int i, JTextArea text1) {
		this.ip = ip;
		this.i = i;
		this.text1 = text1;

	}

	public void run() {

		while (true) {
			try {
				s = new Socket(ip, i);
				text1.setText("连接成功" + "\n");
				break;
			} catch (Exception e) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e1) {
					System.out.println("出错了。。。。");
				}
			}
		}

	}

	public void send(String message) {
		try {

			PrintStream p = new PrintStream(s.getOutputStream());

			p.println(message);

		} catch (Exception e1) {
			System.out.println("异常" + e1.getMessage());
		}
	}

}
最近下载更多
huevnn  LV5 2022年6月16日
xingbing  LV9 2022年1月28日
tangjj7260  LV18 2021年12月10日
wxk666  LV2 2021年9月23日
Aldrin  LV1 2021年4月29日
gdszmgdszmgdszm  LV1 2021年1月11日
wy7481793900  LV18 2020年11月10日
1798672867  LV21 2020年10月8日
wudishan123  LV2 2020年6月14日
我xxx最棒  LV1 2020年4月26日
最近浏览更多
12447680  LV1 4月1日
uni-code_0123  LV1 1月31日
陈小灏  LV14 2023年12月27日
fuyouou  LV5 2023年6月29日
2017143155  LV12 2023年6月24日
didnxjdjfhdk 2023年6月20日
暂无贡献等级
臧家旺  LV3 2023年4月27日
gzryue  LV6 2023年3月8日
kang1919 2023年2月24日
暂无贡献等级
yohohero  LV1 2023年1月14日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友