日期:2014-05-17 浏览次数:20824 次
private void ServerForm_Load(object sender, EventArgs e)
{
//测试线程
Thread SoceketTestThread = new Thread(new ThreadStart(StartListening));
SoceketTestThread.Start();
//实例化
Set_Text = new set_Text(set_ListViewCarFlowText);
}
/// <summary>
/// 开启端口监听线程
/// </summary>
private void StartListening()
{
listener = new TcpListener(IPAddress.Parse(m_serverIP), int.Parse(m_serverPort));
listener.Start();
while (StartListeningFlg)
{
try
{
//一旦在该端口号监听到信息,则启动一个新的线程
Socket s = listener.AcceptSocket();
//判断是否处在连接状态中
if (s.Connected == true)
{
clientsocket = s;
clientservice = new Thread(new ThreadStart(ServiceClient));
clientservice.Start();
}
}
&nbs