T
The Beast
I am trying to use a socket and it says that it can not initialize
it. I have a form with a button that starts this proc and I kept
commenting things out and debugging until I found that the problem
happened on the Create() statement, and I used the switch to findout
what the error was and it comes back "Not Initialized." What could
the problem be?
Here is my code:
void CSocketDlg::OnMail()
{
CString Quit = "128.56.22.8";
unsigned int Error;
// construct a socket
CSocket sockClient;
// create the SOCKET
if(sockClient.Create( )==0)
{
Error = GetLastError();
switch (Error)
{
case WSANOTINITIALISED:
Quit = "Not Initialized";
break;
case WSAENETDOWN:
Quit = "Net Down";
break;
case WSAEAFNOSUPPORT:
Quit = "Address Not Supported";
break;
case WSAEINPROGRESS:
Quit = "Blocking Operation in Progress";
break;
case WSAEMFILE:
Quit = "File Descriptor Unavailable";
break;
case WSAENOBUFS:
Quit = "No buffer space available";
break;
case WSAEPROTONOSUPPORT:
Quit = "Port not supported";
break;
case WSAEPROTOTYPE:
Quit = "port is wrong type";
break;
case WSAESOCKTNOSUPPORT:
Quit = "Sock type not supported";
break;
}
m_Edit1.Insert(0, Quit);
UpdateData(FALSE);
}
/* seek a connection
sockClient.Connect("smtp-server.columbus.rr.com", 0);
if(sockClient.m_hSocket == INVALID_SOCKET)
{
m_Edit1.Insert(0, "Invalid Socket");
UpdateData(FALSE);
}
else
{
// construct file object
CSocketFile file(&sockClient);
// construct an archive
CArchive arIn(&file, CArchive::load);
CArchive arOut(&file, CArchive::store);
// use the archive to pass data:
arOut << Quit;
arIn.Close();
arOut.Close();
}*/
sockClient.Close();
}
Thank you,
The Beast
it. I have a form with a button that starts this proc and I kept
commenting things out and debugging until I found that the problem
happened on the Create() statement, and I used the switch to findout
what the error was and it comes back "Not Initialized." What could
the problem be?
Here is my code:
void CSocketDlg::OnMail()
{
CString Quit = "128.56.22.8";
unsigned int Error;
// construct a socket
CSocket sockClient;
// create the SOCKET
if(sockClient.Create( )==0)
{
Error = GetLastError();
switch (Error)
{
case WSANOTINITIALISED:
Quit = "Not Initialized";
break;
case WSAENETDOWN:
Quit = "Net Down";
break;
case WSAEAFNOSUPPORT:
Quit = "Address Not Supported";
break;
case WSAEINPROGRESS:
Quit = "Blocking Operation in Progress";
break;
case WSAEMFILE:
Quit = "File Descriptor Unavailable";
break;
case WSAENOBUFS:
Quit = "No buffer space available";
break;
case WSAEPROTONOSUPPORT:
Quit = "Port not supported";
break;
case WSAEPROTOTYPE:
Quit = "port is wrong type";
break;
case WSAESOCKTNOSUPPORT:
Quit = "Sock type not supported";
break;
}
m_Edit1.Insert(0, Quit);
UpdateData(FALSE);
}
/* seek a connection
sockClient.Connect("smtp-server.columbus.rr.com", 0);
if(sockClient.m_hSocket == INVALID_SOCKET)
{
m_Edit1.Insert(0, "Invalid Socket");
UpdateData(FALSE);
}
else
{
// construct file object
CSocketFile file(&sockClient);
// construct an archive
CArchive arIn(&file, CArchive::load);
CArchive arOut(&file, CArchive::store);
// use the archive to pass data:
arOut << Quit;
arIn.Close();
arOut.Close();
}*/
sockClient.Close();
}
Thank you,
The Beast