view src/fdl/test2/Server.java @ 53:629b6cfbd37f

metaprotocol ring
author axmo
date Mon, 19 Jan 2009 17:49:14 +0900
parents
children 82a292aa41ad
line wrap: on
line source

package fdl.test2;

import java.net.*;
import java.io.*;
import java.util.*;

public class Server extends Thread{
	static int Port = 10007;
    
	public void run(){
		try {
		ServerSocket server = new ServerSocket(Port);
		Socket sock =null;
		System.out.println("Server Start");
		sock = server.accept();
		System.out.println("Connect");
		PrintWriter ps = new PrintWriter(sock.getOutputStream());
		Date d = new Date();
		ps.print(d + "\r\n");
		ps.flush();
		sock.close(); // クライアントからの接続を切断
	    System.out.println("Connection Closed");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} 

    public static void main(String[] args) {
    	Server sv = new Server();
    	sv.start();
    }
}