Click here to Skip to main content
15,902,299 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDIRECTX DIRECT MUSIC MIDISTATION MIDI Pin
Rance_Wilson19-Oct-07 6:49
Rance_Wilson19-Oct-07 6:49 
Questionc++ options Pin
paulie5419-Oct-07 6:22
paulie5419-Oct-07 6:22 
AnswerRe: c++ options Pin
Mark Salsbery19-Oct-07 6:24
Mark Salsbery19-Oct-07 6:24 
AnswerRe: c++ options Pin
Nemanja Trifunovic19-Oct-07 6:38
Nemanja Trifunovic19-Oct-07 6:38 
GeneralRe: c++ options Pin
Jonathan [Darka]19-Oct-07 7:21
professionalJonathan [Darka]19-Oct-07 7:21 
GeneralRe: c++ options Pin
BadKarma19-Oct-07 7:39
BadKarma19-Oct-07 7:39 
AnswerRe: c++ options Pin
Hamid_RT19-Oct-07 6:58
Hamid_RT19-Oct-07 6:58 
QuestionCrash in CAsyncSocket::Close() Pin
Anorexic Tribble19-Oct-07 2:19
Anorexic Tribble19-Oct-07 2:19 
I am writing a short piece of code to broadcast a UDP packet over a network. It initialises the socket system, created a DGRAM socket, broadcasts the packet and then closes the socket. My problem is that when the Close() function is called it crashes with the message

HEAP[Test.exe]: Invalid Address specified to RtlFreeHeap( 01470000, 0147425C )


Here is the snippit of code :


#define BROADCAST_PORT           9122<br />
<br />
   CAsyncSocket         m_Broadcast_Socket;<br />
   char  Data[] = "1234567890";<br />
   int   Bytes_Sent;<br />
   BOOL  Value;<br />
<br />
<br />
      AfxSocketInit();<br />
<br />
      VERIFY(m_Broadcast_Socket.Create(BROADCAST_PORT, SOCK_DGRAM));<br />
      Value = TRUE;<br />
      VERIFY(m_Broadcast_Socket.SetSockOpt(SO_BROADCAST, &Value, sizeof(BOOL)));<br />
      Bytes_Sent = m_Broadcast_Socket.SendTo((LPCTSTR)Data, 3, BROADCAST_PORT);<br />
      DWORD Error = GetLastError();<br />
      m_Broadcast_Socket.Close();


I can see the packet on my network monitor.

If I take out the SendTo call I have no crash.

If I take out the Close call the destructor crashes (again in the Close call).


What am I doing wrong ?
AnswerRe: Crash in CAsyncSocket::Close() Pin
led mike19-Oct-07 4:15
led mike19-Oct-07 4:15 
GeneralRe: Crash in CAsyncSocket::Close() Pin
Anorexic Tribble19-Oct-07 4:37
Anorexic Tribble19-Oct-07 4:37 
GeneralRe: Crash in CAsyncSocket::Close() Pin
led mike19-Oct-07 5:24
led mike19-Oct-07 5:24 
QuestionCopying from unsigned char * to the CString Pin
ashishbhatt19-Oct-07 2:01
ashishbhatt19-Oct-07 2:01 
AnswerRe: Copying from unsigned char * to the CString Pin
john563219-Oct-07 2:11
john563219-Oct-07 2:11 
GeneralRe: Copying from unsigned char * to the CString Pin
ashishbhatt19-Oct-07 2:23
ashishbhatt19-Oct-07 2:23 
GeneralRe: Copying from unsigned char * to the CString Pin
Tydia-kun19-Oct-07 3:50
Tydia-kun19-Oct-07 3:50 
AnswerRe: Copying from unsigned char * to the CString Pin
Nishad S19-Oct-07 2:13
Nishad S19-Oct-07 2:13 
AnswerRe: Copying from unsigned char * to the CString Pin
James R. Twine19-Oct-07 7:13
James R. Twine19-Oct-07 7:13 
Questionhow to draw a dynamic curve Pin
nibabug19-Oct-07 0:31
nibabug19-Oct-07 0:31 
AnswerRe: how to draw a dynamic curve Pin
jhwurmbach19-Oct-07 0:45
jhwurmbach19-Oct-07 0:45 
GeneralRe: how to draw a dynamic curve Pin
nibabug19-Oct-07 0:51
nibabug19-Oct-07 0:51 
GeneralRe: how to draw a dynamic curve Pin
jhwurmbach19-Oct-07 0:56
jhwurmbach19-Oct-07 0:56 
AnswerRe: how to draw a dynamic curve Pin
chandu00419-Oct-07 0:48
chandu00419-Oct-07 0:48 
GeneralRe: how to draw a dynamic curve Pin
Hamid_RT19-Oct-07 0:57
Hamid_RT19-Oct-07 0:57 
GeneralRe: how to draw a dynamic curve Pin
chandu00419-Oct-07 1:06
chandu00419-Oct-07 1:06 
GeneralRe: how to draw a dynamic curve Pin
Cedric Moonen19-Oct-07 1:11
Cedric Moonen19-Oct-07 1:11 

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.