TCP(2)
-
TCP<Client side>
class ConnectThread extends Thread { String sendMsg; public ConnectThread(String msg) { sendMsg = msg; } public void run() { try { Socket sock = new Socket(ipAddr, port); ObjectOutputStream outstream = new ObjectOutputStream(sock.getOutputStream()); outstream.writeObject(sendMsg); outstream.flush(); sock.close(); } catch(Exception ex) { ex.printStackTrace(); } } }
2014.06.29 -
TCP<Server side>
class outputThread extends Thread {Socket aSocket;ServerFrame serverFrame; public outputThread(Socket sock, ServerFrame sf) { aSocket = sock; serverFrame = sf; } public void run() { try { ObjectInputStream instream = new ObjectInputStream(aSocket.getInputStream());Object obj = instream.readObject();serverFrame.area.append("Input : " + obj+"\n");aSocket.close(); } catch(Exception ex) { ex.printSt..
2014.06.29