Server(2)
-
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 -
UDP<Server side>
static DatagramSocket socket;static DatagramPacket receivePacket;socket = new DatagramSocket(8080); while(true){byte[] buf = new byte[256]; //byte를 선언 합니다.receivePacket = new DatagramPacket(buf, buf.length); socket.receive(receivePacket);String msg = new String(receivePacket.getData(), 0, receivePacket.getLength());msg = new String(msg.getBytes("8859_1"), "KSC5601");//Client로 다시 전송합니다.receivePac..
2014.06.29