1. 程式人生 > >Socket程式設計之伺服器main

Socket程式設計之伺服器main

伺服器端啟動程式入口

package com.server;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer {

    public static void main(String[] args) {
           ServerSocket serivce;
        try {
            serivce = new ServerSocket(30001);
            while (true
) { //等待客戶端連線 Socket socket = serivce.accept(); new Thread(new AndroidRunable(socket)).start(); } } catch (IOException e) { e.printStackTrace(); } } }