|
Have you called WSAStartup() somewhere?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Mark Salsbery wrote: Have you called WSAStartup() somewhere?
Yep. Just a couple of lines before
<br />
int errorCode = WSAStartup(MAKEWORD (2,2), &wsdata);<br />
if (errorCode !=0)<br />
{<br />
ThrowWsaError(errorCode);<br />
return;<br />
}<br />
<br />
if (LOBYTE(wsdata.wVersion) != 2 || HIBYTE(wsdata.wVersion) != 2) <br />
{<br />
throw "Winsock DLL version error ...";<br />
WSACleanup();<br />
return;<br />
}<br />
<br />
smtpSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); <br />
The truth is that I also tried another example (an excerpt from a book) and it happening there also. I tried with VC6, VS2005.
Anyway it runs fine just the question "why" bothers me...
|
|
|
|
|
Zoltan Balazs wrote: It throws an exception at the socket call and if I continue it throws another at the WSACleanup call.
If the socket() call is failing, and you get to the WSACleanup() call, that doesn't sound like
it's running fine.
Strange
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I know.
Try it
|
|
|
|
|
I did!
On a Win32/Multithread DLL CRT/Unicode build, running VS2003 .NET on XP Pro SP2.
I wish I COULD reproduce it! That would make a possible solution SO much easier
Just to make sure I'm following...On the same build, it runs fine outside the debugger
environment (including getting an actual valid, working socket), but when run in the debugger,
the socket() call fails, yet none of the exceptions go beyond first-chance (meaning they were
handled). Is that correct?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Mark Salsbery wrote: Just to make sure I'm following...
Yes, that's correct.
I tried and reproduced also using VS2003 on XP Pro SP2.
The compiler command line is
/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP
and I'm linking against ws2_32.lib.
All has the default settings, just created an empty console project and added ws2_32.lib to the linker.
And thanks for taking the time to check this out.
|
|
|
|
|
I tried your code again on VS 2005 Express (I usually use 2003 .NET) and was still unable to
reproduce it.
I wonder if something is up with your TCP configuration. Here's the output messages I get at
the calls in question...
socket(...)
'TestWin32Console.exe': Loaded 'C:\WINDOWS\system32\wshtcpip.dll', No symbols loaded.
WSACleanup()
'TestWin32Console.exe': Unloaded 'C:\WINDOWS\system32\wshtcpip.dll'
'TestWin32Console.exe': Unloaded 'C:\WINDOWS\system32\hnetcfg.dll'
Something may be failing in your wshtcpip.dll, causing the exception.
Otherwise, I have no clue on this one. I've never had the same problem using Winsock2 and I
haven't heard of others with the same problem either
If I think of something I'll definitely let you know!
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
The strange thing is if I press "Ignore" the socket creation will succeed and I can debug my app.
I will try this on another computer.
|
|
|
|
|
I guess maybe it's ok then, if the socket is created successfully.
First chance exceptions in the debugger are only notifications - you can actually turn them off
so the debugger won't break at the first chance exception but instead will just write a message
to the output window.
Only if the exception goes unhandled - then it's a problem. If you can continue on without
problem after a first-chance exception then that means the exception was handled.
I've just never seen a first-chance exception using sockets
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I tried to turn off the first chance exceptions as shown here http://www.helixoft.com/blog/archives/24[^].
No success though... I still have to try to reproduce this on another computer. I'll get back with results.
Thanks again for the time.
|
|
|
|
|
Hi All,
My Task in vc++ is to save System LogIn and LogOff Times ,Date in A TextFile.
I have No Idea of How to Do.
I search a lot in Net But Unable to get my Requirement
Plz Suggest me to get rid of this.
Thanks In Advance
Nagaraju
|
|
|
|
|
In Windows, I think there's already a logger. check Event Viewer in 'Administrative Tools' in Control panel.
If you still stick with using a text file with your app, you may consider developing an NT Service that after startup and before shutdown of the service gets the current time and date using a time class like:CTime and stores it in a text file.
For writing a simple service Nishant.S. already wrote a perfect article here in CP.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hello,
I want to derive a class from CDialog without resource-ID. How should I use InitModalIndirect() for the dialog initialization?
How should I use DLGTEMPLATE and DLGITEMTEMPLATE structure for the derived class?
Prithaa
|
|
|
|
|
|
prithaa wrote: How should I use DLGTEMPLATE and DLGITEMTEMPLATE structure for the derived class?
That depends on where the dialog template is going to come from. Will you be loading it as a
resource from a module? Will you be creating a template in memory?
The DLGTEMPLATE[^] documentation explains how these structs need to be layed out in memory.
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Problem solved. Thanks.
I need to use this function in c++ console app, and the documentation says:
errno_t <code>_get_pgmptr</code>( char **pValue );
pValue
A pointer to a string to be filled with ...
So I did this:
char *path = new char[MAX_PATH+1];
memset(path, NULL, MAX_PATH + 1);
<code>_get_pgmptr</code>(&path);
...
delete[] path;
But the call to the function, changes the address of the pointer(path) and calling the delete will fail.
I thought first that perhaps, I don't need to allocate any memory and the function (oddly) allocates it automatically and sends me the address but this is not the case either. Can anyone tell me what's wrong with this?
-- modified at 8:18 Tuesday 26th June, 2007
|
|
|
|
|
Hi,
It gets the current value of the _pgmptr, a global variable which contains the file path. You need not allocate the buffer.
What happen if you pass without allocating?
|
|
|
|
|
I found the problem was another mistake! You're right and the function gets a pointer to that variable.
I forgot to remove my question here, I guess I posted too soon, before investigating the code completely. Sorry!
Anyway, Thanks a lot for your attention and reply.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
No need to strike your question, it could be useful for others
|
|
|
|
|
Done.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Thanks from the community
When they kick at your front door
How you gonna come?
With your hands on your head
Or on the trigger of your gun?
Fold with us! ¤ flickr
|
|
|
|
|
Why does te following C++ code flag error?
# include
const int i=10;
void main()
{
const int i = 20;
cout << i << endl << ::i;
cout << &i;
}
The error flagged is "Illegal structure operation in main"
Compiler use : Borland C++ 4.5
How can I access the address of the local and global constant 'i's?
Please help me.
Thanks,
Biju
|
|
|
|
|
Nothing is in front of #include
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Your code print 20 with address of i whats the problem?
|
|
|
|
|
xbiju wrote: How can I access the address of the local and global constant 'i's?
Address of local is &i
Address of global is &::i
In the words of WhiteSky, what's the problem?
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|