Client(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 -
UDP<Client side>
class ConnectThread extends Thread { String sendMsg; String return_msg; public ConnectThread(String msg) { sendMsg = msg; } public void run() { try { DatagramSocket socket = new DatagramSocket(); InetAddress serverAddr = InetAddress.getByName(ipAddr); byte[] buf = new byte[256]; buf = sendMsg.getBytes(); DatagramPacket Packet = new DatagramPacket(buf, buf.length, serverAddr, port); socket.send(P..
2014.06.29