336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(5555);
Socket s;
while (true) {
s = ss.accept();
System.out.println("입장 : " + s.getInetAddress());
PerClientThread pc = new PerClientThread();
pc.s = s;
pc.start();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
public class PerClientThread extends Thread {
public Socket s;
@Override
public void run() {
PrintWriter out = null;
BufferedReader in = null;
try {
out = new PrintWriter(s.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String inputLine;
while((inputLine = in.readLine()) != null)
{
System.out.println( s.getInetAddress() + " : " + inputLine);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
'Programming > JAVA,JSP' 카테고리의 다른 글
JAVA 채팅 프로그램 (0) | 2014.01.21 |
---|---|
JAVA 채팅 예제 #2 (0) | 2014.01.20 |
JAVA 채팅 Client 예제 #1 (0) | 2014.01.20 |
JAVA FIle 실습 #1 (0) | 2014.01.17 |
JAVA File 실습 (0) | 2014.01.17 |