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()); } } }
最近下载更多
zeng1206 LV5
2023年12月28日
微信网友_6712701718712320 LV1
2023年10月29日
yitian111 LV1
2021年10月5日
kraynxn LV8
2021年9月28日
lyws1986 LV17
2021年7月19日
王小懒猪 LV1
2021年6月29日
tim135790 LV1
2021年4月18日
liangge2115 LV27
2021年1月1日
zxp888 LV4
2020年12月18日
zaq123zaq LV10
2020年12月10日
最近浏览更多
zeng1206 LV5
2023年12月28日
微信网友_6712701718712320 LV1
2023年10月29日
阿超在大学修仙 LV1
2023年9月15日
qq1357574774 LV2
2023年7月20日
fuyouou LV5
2023年6月26日
1WQAQW1 LV2
2023年6月12日
aixiao5213 LV1
2022年12月28日
106sadadwd LV2
2022年6月18日
zdm1231 LV2
2022年6月5日
xingbing LV9
2022年1月28日