Socket 的 Util 辅助类 import java
*; import java
*; /** * 2
socket 的 Util 辅助类 * * @author willson * */ public class ClientSocket { private String ip; private int port; private Socket socket = null; DataOutputStream out = null; DataInputStream getMessageStream = null; public ClientSocket(String ip, int port) { this
ip = ip; this
port = port; } /** * 创建 socket 连接 * * @throws Exception * exception */ public void CreateConnection() throws Exception { try { socket = new Socket(ip, port); } catch (Exception e) { e
printStackTrace(); if (socket
= null) socket
close(); throw e; } finally { } } // 发送消息 public void sendMessage(String sendMessage) throws Exception { try { out = new DataOutputStream(socket
getOutputStream()); if (sendMessage
equals("Windows")) { out
writeByte(0x1); out
flush();