sajjad4563
چهارشنبه 22 مرداد 1393, 09:59 صبح
سلام
این کلاس منه که یه HttpServer هست و متناسب با درخواست های client ها، جواب متناسب رو میفرسته:
public class httpServerTest {
static HttpServer server;
public static void main(String[] args) throws Exception {
server = HttpServer.create(new InetSocketAddress(7000), 0);
server.createContext("/", new MyHandler());
server.setExecutor(null); // creates a default executor
server.start();
}
public static class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
// چجوری بوسیله شی t بتونیم آی پی کلاینت رو بدست بیاریم؟
t.getRemoteAddress().getAddress(); // t is 0:0:0:0:0:0:0:
}
}
این کلاس منه که یه HttpServer هست و متناسب با درخواست های client ها، جواب متناسب رو میفرسته:
public class httpServerTest {
static HttpServer server;
public static void main(String[] args) throws Exception {
server = HttpServer.create(new InetSocketAddress(7000), 0);
server.createContext("/", new MyHandler());
server.setExecutor(null); // creates a default executor
server.start();
}
public static class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
// چجوری بوسیله شی t بتونیم آی پی کلاینت رو بدست بیاریم؟
t.getRemoteAddress().getAddress(); // t is 0:0:0:0:0:0:0:
}
}