本文整理汇总了C++中Tcp::getClientSock方法的典型用法代码示例。如果您正苦于以下问题:C++ Tcp::getClientSock方法的具体用法?C++ Tcp::getClientSock怎么用?C++ Tcp::getClientSock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tcp
的用法示例。
在下文中一共展示了Tcp::getClientSock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
DevInfo dev;
Tcp tcp;
Time time;
Gpio gpio;
//gpio.setDirection();
#if MAC_VERIFY
if (!dev.verifyDeviceID()) //Mac Address 불일치
{
cout << "Not Matching MAC ADDRESS" << endl;
exit(-1);
}
#endif
std::thread * threads = new std::thread[MAX_POOL_SIZE];
tcp.makeServerSocket(dev.getPort());
tcp.bindSocket();
tcp.listenSocket(MAX_POOL_SIZE);
for (int i = 0; i < MAX_POOL_SIZE; i++)
{
threads[i] = thread(workerThread, dev, i); //TCP Multi Client Read / Write Thread
}
cp.make("/dev/ttyMAX2", 9600, 'E', 8, 1); //CP 상태용 RS-485
cp.setDebugMode(false);
cp.setSlave(5);
cp.connect();
cp.setRS485Mode();
power.make("/dev/ttyMAX3", 9600, 'N', 8, 1); //전력용 RS-485
power.setDebugMode(false);
power.setSlave(1);
power.connect();
power.setRS485Mode();
wiringPiSetup(); //GPIO lib setup
for (int i = 0; i < MAX_POOL_SIZE; i++)
{
done[i] = false;
}
thread th(statusCP); //CP상태요청 Thread
cout << "[" << time.getCurrentTime() << "] " << "Staring Device Board Server " << endl;
while (1)
{
tcp.acceptSocket();
if (tcp.getClientSock())
{
if (tp.insertMultiMap(tcp.getClientSock(), tcp.getClientIP()))
{
cout << "[" << time.getCurrentTime() << "] " << "Accept(" << tcp.getClientIP() << ")" << "::SEND SIGNAL(" << tp.getIndexNum() << ")" << endl;
std::unique_lock<std::mutex> lock(mtx);
lock.unlock();
cond[tp.getIndexNum()].notify_one(); //Wait 된 Thread에게 Signal을 보냄
usleep(1000);
lock.lock();
}
else
{
tcp.closeClientSock();
}
}
}
threads->join();
th.join();
}