Click here to Skip to main content
16,008,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalrichedit and htmlview Pin
Mazdak4-Dec-01 6:16
Mazdak4-Dec-01 6:16 
GeneralIIS Pin
mazy4-Dec-01 6:10
mazy4-Dec-01 6:10 
GeneralRe: IIS Pin
RobJones4-Dec-01 9:44
RobJones4-Dec-01 9:44 
GeneralIWebBrowser2 interface in IE automation Pin
Andy Latham4-Dec-01 5:30
Andy Latham4-Dec-01 5:30 
GeneralBitmap and Device Context Pin
pepeR4-Dec-01 4:39
pepeR4-Dec-01 4:39 
GeneralRe: Bitmap and Device Context Pin
Chris Losinger4-Dec-01 4:43
professionalChris Losinger4-Dec-01 4:43 
GeneralCTime ASSERT Pin
Edilson Vasconcelos de Melo Junior4-Dec-01 4:27
Edilson Vasconcelos de Melo Junior4-Dec-01 4:27 
GeneralWindows Sockets Question Pin
Aaron Schaefer4-Dec-01 4:02
Aaron Schaefer4-Dec-01 4:02 
Hi All,

I'm having some trouble debugging the following function under Windows 2000 w/ Visual Studio 6.0. Where the function calls the socket API function, the debugger is reporting the following:

HEAP[Sockets.exe]: Heap block at 00140390 modified at 0014070E past requested size of 376
HEAP[Sockets.exe]: Invalid Address specified to RtlReAllocateHeap( 130000, 140398 )

Does anyone see something that I am missing? This function appears to work correctly when executed outside of the debugger (the socket gets bound and can accept connections from other machines), but . . .

Here is the code I am testing:

// Creates a socket in the local machine
SOCKET CreateLocalSocket(int port)
{
SOCKET s = INVALID_SOCKET;
char localHost[256];
hostent* pHostEntry = NULL;
sockaddr_in sa;

// Get the name of this machine
printf("\ngetting local host name . . .");
if(0 != gethostname(localHost, 256))
{
printf("failed.");
return s;
}
else
printf("succeeded.");
printf("\nlocal host name = <%s>", localHost);

// Deprecated function call
printf("\ngetting local host address info . . .");
pHostEntry = gethostbyname(localHost);
if(pHostEntry == NULL)
{
printf("failed.");
return s;
}
else
printf("succeeded.");

// Create a socket
printf("\ncreating socket . . .");
s = socket(AF_INET, SOCK_STREAM, 0);
if(s == INVALID_SOCKET)
{
printf("failed.");
return s;
}
else
printf("succeeded.");

// Set up the socket address struct
memset(&sa, 0, sizeof(sa));
sa.sin_family = pHostEntry->h_addrtype;
sa.sin_port = htons(port);

printf("\nbinding socket . . .");
if(0 != bind(s, (sockaddr*)&sa, sizeof(sa)))
{
printf("failed.");
return s;
}
else
printf("succeeded.");

return s;
}

Thanks in advance for any help.
GeneralProblems in Visual C++ Pin
Js0n4-Dec-01 3:49
Js0n4-Dec-01 3:49 
GeneralRe: Problems in Visual C++ Pin
Ravi Bhavnani4-Dec-01 8:38
professionalRavi Bhavnani4-Dec-01 8:38 
QuestionCan you have ranges in a switch statement? Pin
Chambers4-Dec-01 1:30
Chambers4-Dec-01 1:30 
AnswerRe: Can you have ranges in a switch statement? Pin
Michael P Butler4-Dec-01 1:51
Michael P Butler4-Dec-01 1:51 
GeneralRe: Can you have ranges in a switch statement? Pin
Chambers4-Dec-01 2:11
Chambers4-Dec-01 2:11 
AnswerRe: Can you have ranges in a switch statement? Pin
Alvaro Mendez4-Dec-01 4:59
Alvaro Mendez4-Dec-01 4:59 
AnswerRe: Can you have ranges in a switch statement? Pin
Jon Sagara4-Dec-01 5:18
Jon Sagara4-Dec-01 5:18 
AnswerRe: Can you have ranges in a switch statement? Pin
Chambers4-Dec-01 5:39
Chambers4-Dec-01 5:39 
AnswerRe: Can you have ranges in a switch statement? Pin
Ravi Bhavnani4-Dec-01 5:48
professionalRavi Bhavnani4-Dec-01 5:48 
GeneralRe: Can you have ranges in a switch statement? Pin
Chambers4-Dec-01 6:38
Chambers4-Dec-01 6:38 
GeneralA stupid question. Pin
The_Server4-Dec-01 1:26
The_Server4-Dec-01 1:26 
GeneralRe: A stupid question. Pin
Michael P Butler4-Dec-01 1:48
Michael P Butler4-Dec-01 1:48 
GeneralRe: A stupid question. Pin
Alvaro Mendez4-Dec-01 5:04
Alvaro Mendez4-Dec-01 5:04 
GeneralRe: A stupid question. Pin
RobJones4-Dec-01 10:14
RobJones4-Dec-01 10:14 
Generaledit resources Pin
4-Dec-01 0:49
suss4-Dec-01 0:49 
GeneralUsing variable argument lists Pin
neilbennevis4-Dec-01 0:36
neilbennevis4-Dec-01 0:36 
GeneralRe: Using variable argument lists Pin
Bill Wilson4-Dec-01 9:53
Bill Wilson4-Dec-01 9:53 

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.