关于多线程~~~~???? 我设计一个多线程的TCP/IP的通信程序,不知可否使所有的线程对一个端口进行监听!可否讲讲思路!贴源代码最好! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知这样是否可以!我的调试在AfxBeginThread()处通不过!UINT SocketListen(void* pPort)//CSocket& socket,CString& ip,UINT& port){ CMySocket socket; UINT Port=*pPort; socket.Create(Port,SOCK_STREAM,"127.0.0.1"); socket.Bind(Port,"127.0.0.1"); socket.Listen(5); socket.Accept(dlg->m_ConnServer); socket.Close(); return 0;}CServerDlg::OnListen(){UINT port=6801;while(1 && port<6805){ CWinThread* hHandle; hHandle=AfxBeginThread(SocketListen,(LPVOID)port); if (hHandle ==NULL) { MessageBox("ERROR: Unable to create thread!","NO",MB_OK); } else //已接受一个客户端的连接 { if(port<6805) port++; }}错误为:error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (__cdecl *)(unsigned int *)' 这个问题已解决!但好像没效果!Why? 我也对这个问题感兴趣啊,我正在写一个tcp/ip的传送文件的东西也用到这些的,有空讨论一下[email protected] VC如何通过文件路径加载资源 设计视图如何快速切换到代码视图(net2005) NT Service程序如何访问局域网上其他机器的共享路径? 求助:初学VC数据库编程(ODBC) 求救动态创建菜单问题!急!!!!! 问题2 小问题-怎样在多文档窗口中启动时自窗口充满整个框架,且不可改变子窗口的大小 关于ADO的困惑!!! 我想用纯代码生成.chm,只使用(并且只能使用)二进制文件写入功能?分不够再加!! 请问COM调用DLL的底层是否也要用到LoadLibrary()? 请大家提些意见...... (200分)看看里面的文章,见者有分,满20人结。。。
{
CMySocket socket;
UINT Port=*pPort;
socket.Create(Port,SOCK_STREAM,"127.0.0.1");
socket.Bind(Port,"127.0.0.1");
socket.Listen(5);
socket.Accept(dlg->m_ConnServer);
socket.Close();
return 0;
}CServerDlg::OnListen()
{
UINT port=6801;
while(1 && port<6805)
{
CWinThread* hHandle;
hHandle=AfxBeginThread(SocketListen,(LPVOID)port);
if (hHandle ==NULL)
{
MessageBox("ERROR: Unable to create thread!","NO",MB_OK);
}
else //已接受一个客户端的连接
{
if(port<6805)
port++;
}
}错误为:
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (__cdecl *)(unsigned int *)'
但好像没效果!
Why?
tcp/ip的传送文件的东西
也用到这些的,有空讨论一下
[email protected]