package com.dev_fbs9600s.data;
|
|
import java.io.IOException;
|
import java.net.ServerSocket;
|
import java.net.Socket;
|
import java.net.SocketTimeoutException;
|
|
import com.battmonitor.data.BattData_RT_Array;
|
import com.battmonitor.sql.MysqlConnPool;
|
|
public class FBS9600S_ServerSocket_Thread extends Thread{
|
|
public MysqlConnPool m_ConnPool = null;
|
public BattData_RT_Array m_Data;
|
public ServerSocket m_ServerSocket = null;
|
|
public FBS9600S_ServerSocket_Thread(MysqlConnPool pool, BattData_RT_Array data)
|
{
|
m_ConnPool = pool;
|
m_Data = data;
|
}
|
|
@Override
|
public void run() {
|
|
System.out.println(this.getName() + " - FBS9600S_ServerSocket_Thread Started On Port 9101");
|
while(true) {
|
try {
|
this.m_ServerSocket = new ServerSocket(9600);
|
while(true) {
|
this.m_ServerSocket.setSoTimeout(600000); //600 seconds
|
|
Socket tmp_socket = this.m_ServerSocket.accept();
|
FBS9600S_SocketClient_Thread thread = new FBS9600S_SocketClient_Thread(this.m_ConnPool,m_Data,tmp_socket);
|
thread.start();
|
/*
|
try {
|
Thread.sleep(100);
|
} catch (InterruptedException e1) {
|
// TODO Auto-generated catch block
|
e1.printStackTrace();
|
}
|
*/
|
//-----------------------------------------------------------------------------------------//
|
}
|
} catch (SocketTimeoutException e1) {
|
//System.err.println(e1.getMessage());
|
} catch (IOException e) {
|
System.err.println(e.getMessage());
|
} finally {
|
try {
|
Thread.sleep(1000);
|
if(null != this.m_ServerSocket) {
|
this.m_ServerSocket.close();
|
}
|
} catch (IOException | InterruptedException e1) {
|
e1.printStackTrace();
|
}
|
}
|
}
|
}
|
}
|