Click here to Skip to main content
15,891,633 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: pls this bug Pin
normanS4-Sep-05 20:09
normanS4-Sep-05 20:09 
GeneralRe: pls this bug Pin
neodeaths5-Sep-05 7:16
neodeaths5-Sep-05 7:16 
Questionswitch vs. if Pin
JKallen3-Sep-05 16:00
JKallen3-Sep-05 16:00 
AnswerRe: switch vs. if Pin
Cliff Hatch3-Sep-05 23:10
Cliff Hatch3-Sep-05 23:10 
AnswerRe: switch vs. if Pin
Tim Smith4-Sep-05 3:30
Tim Smith4-Sep-05 3:30 
AnswerRe: switch vs. if Pin
Gary R. Wheeler4-Sep-05 5:19
Gary R. Wheeler4-Sep-05 5:19 
GeneralRe: switch vs. if Pin
JKallen5-Sep-05 9:58
JKallen5-Sep-05 9:58 
QuestionCObList::GetNext return Different value ??? Pin
3-Sep-05 15:34
suss3-Sep-05 15:34 
////////////////////////////func A: App's member function ////////////////////////////////////////////////////

newIndex = pRWapp->GetEmptySocket();
if ( newIndex != -1 )
{
myOver = &(pRWapp->m_clientStructArray[newIndex]);
SOCKADDR_IN clntAddr;
int addrLen = sizeof(clntAddr);

myOver->socket = accept( pRWapp->m_serverSocket, (SOCKADDR*)&clntAddr, &addrLen );
if(pRWapp->m_bKillThreads==TRUE)
{
return 0L;
}

if(myOver->socket == INVALID_SOCKET)
{
// this area left out...for shortness
}

memcpy(&(myOver->clntAddr),&clntAddr,addrLen);

if ( myOver->socket != INVALID_SOCKET )
{
user = newIndex * 2;

ZeroMemory( &(myOver->recvOverlapped.Overlapped), sizeof(OVERLAPPED) );
ZeroMemory( &(myOver->sendOverlapped.Overlapped), sizeof(OVERLAPPED) );

CreateIoCompletionPort( (HANDLE)(myOver->socket),

pRWapp->m_gCompletionPort, DWORD(myOver), 0 );

myOver->recvOverlapped.wsabuf.buf = myOver->recvOverlapped.buffer;

myOver->recvOverlapped.wsabuf.len = BUFSIZE - 1;

==> this Func A 's function is to save data to m_clientStructArray[]....


////////////////////////////func B : App's member function ////////////////////////////////////////////////////

CPortClientScks* pPortCliSkc = new CPortClientScks;
pPortCliSkc->sockHandle = m_clientStructArray[index];
m_XXX_Port_SockList.AddTail(pPortCliSkc);


==> func B 's function is to save m_clientStructArray 's content to m_XXX_Port_SockList....

////////////////////////////func C: App's function////////////////////////////////////////////////////

POSITION sndXXXPos ;
sndXXXPos = m_XXX_Port_SockList.GetHeadPosition();
CPortClientScks* pSndXXXSck = NULL;

while(sndXXXPos != NULL )
{
pSndXXXSck = (CPortClientScks*)m_XXX_Port_SockList.GetNext(sndXXXPos);
if(m_pSndXXXSck->sockHandle.ID != "")
{
DWORD sendbytes;
strncpy(pSndXXXSck->sockHandle.sendOverlapped.wsabuf.buf,(LPCTSTR) pByte, bytes);
pSndXXXSck->sockHandle.sendOverlapped.wsabuf.len = bytes;

WSASend( pSndXXXSck->sockHandle.socket, &(pSndXXXSck->sockHandle.sendOverlapped.wsabuf),1,

&sendbytes, 0, &(pSndXXXSck->sockHandle.sendOverlapped.Overlapped), NULL );
}
}

//////////////////////////// following three lines are added to last of func C to check out the content of m_XXX_Port_SockList /////////////////////

sndXXXPos = m_XXX_Port_SockList.GetHeadPosition();
if(sndXXXPos != NULL)
pSndXXXSck = (CPortClientScks*)m_XXX_Port_SockList.GetNext(sndXXXPos);

==> func C' function is to look over m_XXX_Port_SockList's content...



and the structure of SOCKHANDLE IS....

typedef struct _MYSOCKHANDLE
{
SOCKET socket;
char ID[MAX_ID_LEN];
SOCKADDR_IN clntAddr;
MYOVERLAPPED recvOverlapped;
MYOVERLAPPED sendOverlapped;
}SOCKHANDLE, *LPSOCKHANDLE;

this SOCKHANDLE structure is used at m_clientstructArray[], and m_xxx_port_sockList's node member
the problem of this my code is that Getnext returns different value at second GetNext at added 3 lines especially after comed out of func C 's while loop....

but pPortCliSkc's value returned from func B 's new has proper value....
but, func C 's added GetNext return another value.....

why this happens?

GetHeadPosition 's return value is always same but
GetNext value is different , inside of Fucn C's while loop first entered,
but come out of while loop and added Getnext's return value is different ?
why?

please help me....


-- modified at 21:36 Saturday 3rd September, 2005
QuestionInclude <fstream.h> Pin
kenexcelon3-Sep-05 15:12
kenexcelon3-Sep-05 15:12 
AnswerRe: Include <fstream.h> Pin
Jack Puppy3-Sep-05 15:19
Jack Puppy3-Sep-05 15:19 
AnswerRe: Include &lt;fstream.h&gt; Pin
Axter3-Sep-05 15:43
professionalAxter3-Sep-05 15:43 
QuestionCRecordset &amp; LIMIT (sql statement) Pin
maTzeLein3-Sep-05 11:08
maTzeLein3-Sep-05 11:08 
QuestionProblem with Memory usage of a program Pin
rajeevktripathi3-Sep-05 3:59
rajeevktripathi3-Sep-05 3:59 
AnswerRe: Problem with Memory usage of a program Pin
Bob Stanneveld3-Sep-05 4:59
Bob Stanneveld3-Sep-05 4:59 
QuestionDifferentiating New file creation and Open in CreateFile Pin
ragavan3-Sep-05 3:51
ragavan3-Sep-05 3:51 
QuestionIcon association with non-executable file Pin
johnnyXP3-Sep-05 2:25
johnnyXP3-Sep-05 2:25 
AnswerRe: Icon association with non-executable file Pin
PJ Arends3-Sep-05 9:59
professionalPJ Arends3-Sep-05 9:59 
AnswerRe: Icon association with non-executable file Pin
Ravi Bhavnani4-Sep-05 6:44
professionalRavi Bhavnani4-Sep-05 6:44 
AnswerRe: Icon association with non-executable file Pin
Gary R. Wheeler4-Sep-05 6:50
Gary R. Wheeler4-Sep-05 6:50 
QuestionAnyone can help me about Html Help Workshop? Pin
Anonymous3-Sep-05 1:54
Anonymous3-Sep-05 1:54 
AnswerRe: Anyone can help me about Html Help Workshop? Pin
Gary R. Wheeler3-Sep-05 2:18
Gary R. Wheeler3-Sep-05 2:18 
QuestionFinding the same function in VC++ Pin
KaGeU3-Sep-05 0:09
KaGeU3-Sep-05 0:09 
AnswerRe: Finding the same function in VC++ Pin
toxcct3-Sep-05 0:29
toxcct3-Sep-05 0:29 
GeneralRe: Finding the same function in VC++ Pin
KaGeU3-Sep-05 0:46
KaGeU3-Sep-05 0:46 
QuestionShortcut keys - Runtime? Pin
G Haranadh2-Sep-05 23:39
G Haranadh2-Sep-05 23:39 

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.