Click here to Skip to main content
15,900,648 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can I use both winsock.h and winsock2.h in same app? Or is that not good? Please don't delete this. Rather answer the question, it takes just as much energy to be nice as it does to be mean. (Even if you think it'a a stupid question) Yes or No would do nicely!
Posted
Comments
Sergey Alexandrovich Kryukov 3-Aug-11 13:12pm    
I do not know (or don't remember) which of your posts were removed, but it could have happened if your post is not a question or inappropriate otherwise, completely off-topic, is a re-port of your other post, or, in rare cases, incomprehensible beyond repair (so there is no hope to improve a question by asking for clarification).

Your current question, by the way, is quite appropriate and not stupid.

Usually you receive a comment and e-mail notification about the reasons of removal.

After all, a question could be removed accidentally.

Questions are usually not removed just because of the poor knowledge of the inquirer -- after all, we help to learn things. However, there were cases when the inquirer apparently ignores the advices and repeat the same mistake in more and more questions; it could cause massive removal of annoying spam-like questions. It happened rarely; I don't think this is your case.

--SA
Member 7766180 3-Aug-11 20:09pm    
Thank you!!1

If you look inside winsock2.h, you can see that it includes windows.h.
And if you look inside windows.h, you can see that it includes winsock.h.
But winsock2.h makes sure that none of the contents of winsock.h are valid by defining _WINSOCKAPI_.

Here is the line from winsock2.h -
C#
#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */

And if you look inside winsock.h, all its contents are with these statments -
C#
#ifndef _WINSOCKAPI_

#endif

So in short, you must not use both together.
 
Share this answer
 
Comments
Member 7766180 3-Aug-11 20:09pm    
Thank You, a very intelligent answer to a not so stupid question afterall! :) I thank you for your time, understanding and patience!
You can but it will just cause problems; use one or the other.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900