473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sockets in Visual Studio 6 on XP

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
Jul 22 '05 #1
2 2347

"The Beast" <Ob********@columbus.rr.com> schrieb im Newsbeitrag
news:eh********************************@4ax.com...
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


make sure you call
BOOL AfxSocketInit( WSADATA* lpwsaData = NULL );
to initialize Windows sockets!
Jul 22 '05 #2
On Thu, 26 Aug 2004 09:27:09 +0200, "Friedrich Neurauter"
<fr*****************@eunet.at> wrote:
make sure you call
BOOL AfxSocketInit( WSADATA* lpwsaData = NULL );
to initialize Windows sockets!


Thank YOU!! That fixed the problem with the sockets!! You would
think that it would say something about that in the example it gives
in MSDN, oh well, now I have some other problems to work on, so I may
be back!! Thank you again!

The Beast
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: paulbubach | last post by:
Hi @all, we have the following problem. We have developed an application with the Visual Studio.Net 2002 and the project runs on it. But now we have change the version of the Studio and now we...
0
by: mrpolitics | last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd) and everything was fine untill yesterday when the server crashed. So I did a cold restart and staretd the server back up...
1
by: osaleh | last post by:
I am trying to execute a Socket.Select() statement on an arraylist of sockets. The problem is that I can only go up to 64 sockets at a time. I know that I have to manupilate the FD_SetSize to...
6
by: Laxmikant Rashinkar | last post by:
Is there any way to use a C# socket in promiscuous mode? Any sample code that shows how this is done? any assistance is much appreciated! thanks LK
4
by: WAkthar | last post by:
I am in the process of converting an MFC client and server application to C#. The communication between the client and server was done using simple WM_COPYDATA. I want to use sockets for the C#...
5
by: mak | last post by:
Dear Friends, I'm working on real time stock quotes display. Using Async tcp sockets in .net csharp. Client software running perfect on LAN and ISDN but not good on ip dialup. After lot of...
3
by: Sven | last post by:
My current application is programmed in Visual Basic 6.0 It is a server and uses the winsock-control Now I have learned that the winsock control is not (fully) supported by VB.NET and that I...
15
by: mrpolitics | last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd) and everything was fine untill yesterday when the server crashed. So I did a cold restart and staretd the server back up...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.