package com.mir.video.socket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import com.mir.Global;

/**
 * ClassName:SocketListener
 * 
 * @author <font color="red">Edson</font>
 * @version
 * @since Ver 1.1
 * @Date 2014年6月27日 下午6:08:22
 * 
 * @see
 */
public class SocketListener extends Thread {
	private static ServerSocket server = null;
	private Socket socket = null;

	/**
	 * Creates a new instance of SocketListener.<br>
	 * 无参构造器 启动SocketServer
	 */
	public SocketListener() {
		try {
			server = new ServerSocket(Global.PORT);
			System.out.println("Socket Server Start");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws IOException {
		new SocketListener().start();
	}

	@Override
	public void run() {
		while (true) {
			try {
				// 建立连接,每个连接交由一个线程来处理
				socket = server.accept();
				System.out.println("Create New Socket connection");
				new FileSocketWrite(socket).start();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
最近下载更多
myj2006  LV11 2019年8月30日
18089237297  LV3 2019年4月26日
pzg8616235  LV8 2018年9月10日
lhyi23  LV1 2018年6月11日
华丽的孤单331  LV9 2018年6月4日
zs3480  LV11 2018年2月3日
15943876586  LV17 2017年2月7日
都市书  LV4 2016年11月15日
gjynewer  LV15 2016年9月2日
gutong  LV10 2015年10月3日
最近浏览更多
dapeng0011  LV13 2月25日
飞翔的面包片  LV12 2023年12月19日
pangzhihui  LV11 2023年12月15日
lironggang  LV38 2023年6月13日
aq384419 2023年4月15日
暂无贡献等级
超维智能编程  LV6 2023年2月26日
nywgzhc  LV10 2022年11月20日
mc0624 2022年10月13日
暂无贡献等级
爱情戴罪的羔羊  LV7 2022年9月9日
zhezhizhu123  LV1 2022年7月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友