import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class SocketServer {
// 포트번호 입력
public SocketServer(int port) {
try {
ServerSocket sServer = new ServerSocket(port);
while(true) {
System.err.println("연결 대기중......");
Socket socket = sServer.accept();
InputStream is = socket.getInputStream();
byte[] b = new byte[10240];
int readCount = is.read(b);
System.out.println(new String(b, 0, readCount));
OutputStream os = socket.getOutputStream();
os.write(b, 0, readCount);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
RECENT COMMENT