心殇
unread,Jul 5, 2009, 10:46:03 PM7/5/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spserver
下面的代码是我创建很多socket的代码
SP_LFServer* MainWindow::CreatSocket(const char * bindIP, int port,
int maxThreads,
int maxConnections,
int reqQueueSize,
int timeout)
{
SP_LFServer* spSvr = new SP_LFServer(bindIP,port,new
SP_SvrHandlerFactory());
spSvr->setTimeout( timeout );
spSvr->setMaxConnections( maxConnections );
spSvr->setMaxThreads( maxThreads );
spSvr->setReqQueueSize( reqQueueSize, "Sorry, server is busy now!
\n" );
spSvr->run();
return spSvr;
}
我在初始化的时候创建socket server
QStandardItem* item;
for (int i = 0; i < m_model->rowCount(); i++)
{
item = m_model->item(i,1);
//server
m_spSvr.append(CreatSocket(m_strServerIp.c_str(),item->text
().toInt()));
item = m_model->item(i,2);
//web
m_spSvr.append(CreatSocket(m_strWebIp.c_str(),item->text
().toInt()));
}
但是问题出现了,客户端只能连接循环第一次打开的端口,其他的端口不能连接。
比如 循环6次 每次打开的端口是7000,7001,7002,6000,6001,6002
但是我只能连接7000