53
|
1 package fdl.test2;
|
|
2
|
|
3 import java.net.*;
|
|
4 import java.io.*;
|
|
5 import java.util.*;
|
|
6
|
|
7 public class Server extends Thread{
|
|
8 static int Port = 10007;
|
|
9
|
|
10 public void run(){
|
|
11 try {
|
|
12 ServerSocket server = new ServerSocket(Port);
|
|
13 Socket sock =null;
|
|
14 System.out.println("Server Start");
|
|
15 sock = server.accept();
|
|
16 System.out.println("Connect");
|
|
17 PrintWriter ps = new PrintWriter(sock.getOutputStream());
|
|
18 Date d = new Date();
|
|
19 ps.print(d + "\r\n");
|
|
20 ps.flush();
|
|
21 sock.close(); // クライアントからの接続を切断
|
|
22 System.out.println("Connection Closed");
|
|
23 } catch (IOException e) {
|
|
24 // TODO Auto-generated catch block
|
|
25 e.printStackTrace();
|
|
26 }
|
|
27 }
|
|
28
|
|
29 public static void main(String[] args) {
|
|
30 Server sv = new Server();
|
|
31 sv.start();
|
|
32 }
|
|
33 } |