Click here to Skip to main content
15,917,565 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is there any way to convert resource name to resource id? Pin
Stuart Dootson18-Jul-09 13:20
professionalStuart Dootson18-Jul-09 13:20 
QuestionControls flickering, (buttons over a static control) Pin
Netc18-Jul-09 9:36
Netc18-Jul-09 9:36 
AnswerRe: Controls flickering, (buttons over a static control) Pin
transoft18-Jul-09 11:53
transoft18-Jul-09 11:53 
GeneralRe: Controls flickering, (buttons over a static control) Pin
Netc18-Jul-09 13:20
Netc18-Jul-09 13:20 
AnswerRe: Controls flickering, (buttons over a static control) Pin
Moak19-Jul-09 5:41
Moak19-Jul-09 5:41 
QuestionCSocket::Create function has thrown exception Pin
Elsie18-Jul-09 5:31
Elsie18-Jul-09 5:31 
AnswerRe: CSocket::Create function has thrown exception Pin
Moak19-Jul-09 3:38
Moak19-Jul-09 3:38 
AnswerRe: CSocket::Create function has thrown exception Pin
decentsmile28-Jan-10 6:04
decentsmile28-Jan-10 6:04 
Hi Guys,

This same problem has driven me nuts but finally i fixed it and it is working. This is bug with MFC socket library that when inside a thread [other than main application thread], If we try to do something like

CSocket socket;<br />
socket.Create();

It will throws an unhandled exception. I found an article on it See What Microsoft says about this

that said something from Microsoft but that did not help me either. So here is a workaround i have found and i hope it can help some frustrated fellow like me.

Inside thread, do this

CSocket mySock;<br />
SOCKET sockethandle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br />
mySock.m_hSocket= sockethandle;

After that DO NOT call mySock.Create as it has been created already through assignment of socket handle. I am not sure if we can use mySock.Attach(sockethandle) as i did not try it yet.

After that you can call Connect etc directly.

When you are done using the socket, DO NOT call
<code></code>mySock.Close()
- rather call

closesocket(mySock.m_hSocket); And that will free the socket object. If Attach works in above case then i guess we need to do Detach here when to free the socket.

Good Luck
Nauman Khan
QuestionDestructor Pin
Gjm18-Jul-09 3:17
Gjm18-Jul-09 3:17 
AnswerRe: Destructor Pin
Stuart Dootson18-Jul-09 3:29
professionalStuart Dootson18-Jul-09 3:29 
AnswerRe: Destructor Pin
Bram van Kampen18-Jul-09 15:22
Bram van Kampen18-Jul-09 15:22 
AnswerRe: Destructor Pin
Iain Clarke, Warrior Programmer19-Jul-09 8:16
Iain Clarke, Warrior Programmer19-Jul-09 8:16 
GeneralUninstallation of Visual C++ 8.0 ATL (x86) WinSXS MSM Pin
VictorSotnikov18-Jul-09 2:36
VictorSotnikov18-Jul-09 2:36 
QuestionCreating new object from type_info (typeid) Pin
Tomas(cz)18-Jul-09 2:13
Tomas(cz)18-Jul-09 2:13 
AnswerRe: Creating new object from type_info (typeid) Pin
Stuart Dootson18-Jul-09 2:55
professionalStuart Dootson18-Jul-09 2:55 
GeneralRe: Creating new object from type_info (typeid) Pin
Tomas(cz)18-Jul-09 5:44
Tomas(cz)18-Jul-09 5:44 
GeneralRe: Creating new object from type_info (typeid) Pin
Stuart Dootson18-Jul-09 7:24
professionalStuart Dootson18-Jul-09 7:24 
AnswerRe: Creating new object from type_info (typeid) Pin
Bram van Kampen18-Jul-09 15:35
Bram van Kampen18-Jul-09 15:35 
QuestionHow to save a bitmap in Visual c++ (mfc)? Pin
Sakthi.Gs :-)18-Jul-09 0:43
Sakthi.Gs :-)18-Jul-09 0:43 
AnswerRe: How to save a bitmap in Visual c++ (mfc)? Pin
Iain Clarke, Warrior Programmer18-Jul-09 1:05
Iain Clarke, Warrior Programmer18-Jul-09 1:05 
AnswerRe: How to save a bitmap in Visual c++ (mfc)? Pin
ravidborse20-Jul-09 3:17
ravidborse20-Jul-09 3:17 
QuestionCRECT height Pin
kumar sanghvi18-Jul-09 0:03
kumar sanghvi18-Jul-09 0:03 
AnswerRe: CRECT height Pin
Naveen18-Jul-09 0:11
Naveen18-Jul-09 0:11 
GeneralRe: CRECT height Pin
kumar sanghvi18-Jul-09 0:40
kumar sanghvi18-Jul-09 0:40 
GeneralRe: CRECT height Pin
Iain Clarke, Warrior Programmer18-Jul-09 1:02
Iain Clarke, Warrior Programmer18-Jul-09 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.