本文介绍了错误代码10038的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的程序中出现未知错误.
如果有人知道请解释一下我.
在这里,我正在使用CSocket来访问服务器client.我正在将数据库记录从服务器发送到客户端.
Hi guys i am getting an unknown error in my program.
if any one knows pls explain me.
Here i am using CSocket for server, client.I am sending my database records from server to client.
//Thread Parameter
struct Param
{
SOCKET hServer; // Handler
}
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008);
if(!personalRS.Open())
AfxMessageBox(_T("Database open failed"));
else
{
LocalIP(strLocalIP);
m_server.Create(999, SOCK_STREAM);
m_server.Bind(999, (LPCTSTR)strLocalIP[0]); // creating server and thread on my application loading
m_server.Listen();
Param p;
p.hServer = m_server.Detach();
pThread = AfxBeginThread(Thread,(LPVOID)&p);
}
}
//Thread function...
UINT Thread(LPVOID lpParam)
{
Param param = *((Param*)lpParam);
CSocket server;
CSocket client;
server.Attach(param.hServer);
while(TRUE)
{
UINT nPort;
if(server.Accept(client))
{
//My sending Process
}
else
{
DWORD n = GetLastError();
CString str;
str.Format(_T("%ld"), n);
AfxMessageBox(str); //Here i am getting ErrorCode 10038
} // descryption for errorcode in msdn local help is below
//WSAENOTSOCK 10038 - An operation was attempted
// on something that is not a socket.
}
server.Close();
return 0;
}
我不知道我的代码有什么问题.
感谢advace
ganesh_IT
i dont know whats wrong in my code.
Thanks in advace
ganesh_IT
推荐答案
CSocket server;
server.Create(PRE_AGREED_PORT);
server.Listen();
CSocket client;
server.Accept(client);
您是否尝试过使用Visual Studio附带的调试器?在大多数情况下,单步执行代码会向您显示您的实际问题.
Have you tried using the debugger that comes with Visual Studio? Most of the time, stepping through the code will reveal your actual problem to you.
这篇关于错误代码10038的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!