Click here to Skip to main content
16,007,858 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: closing Messagebox Pin
thammadi19-Jul-07 23:17
thammadi19-Jul-07 23:17 
AnswerRe: closing Messagebox Pin
David Crow20-Jul-07 3:30
David Crow20-Jul-07 3:30 
AnswerRe: closing Messagebox Pin
Hamid_RT31-Jul-07 19:26
Hamid_RT31-Jul-07 19:26 
QuestionSHCreateStreamOnFileW() problem Pin
josip cagalj19-Jul-07 22:12
josip cagalj19-Jul-07 22:12 
AnswerRe: SHCreateStreamOnFileW() problem Pin
tanvon malik19-Jul-07 23:02
tanvon malik19-Jul-07 23:02 
GeneralRe: SHCreateStreamOnFileW() problem [modified] Pin
josip cagalj20-Jul-07 0:04
josip cagalj20-Jul-07 0:04 
AnswerRe: SHCreateStreamOnFileW() problem Pin
Michael Dunn21-Jul-07 10:14
sitebuilderMichael Dunn21-Jul-07 10:14 
Questionproblem in communication with UDP Pin
whiteclouds19-Jul-07 22:06
whiteclouds19-Jul-07 22:06 
Hi, everyone!
I've a problem about UDP. I don't know whether this should be submitted here. If shouldn't, plz tell me the apporiate position.
I'm developing an application which can communicate with other machine through Network using UDP. I create a new thread to listen the income. This thread function is a member of the class manageing the socket. I find a strange phenomenon that I must destroy the thread and create a new one after I send message. Or I can't receive anything from the target I had just sent to. I think the actual fact shouldn't be as this. But I don't know the reason. So I hope someone can help me to resolve this problem. Thx!
The fraction of the thread function:
UINT CMySocket::ReceiveThread(LPVOID lpParam)
{
CMySocket *parent=reinterpret_cast(lpParam);
BYTE buf[1024];
DWORD dwLength;
int ret,addrlen,err;
CWinThread* AcptThread;
fd_set fdread;
SOCKET ListenSock,ClientSock;
ClientSock=parent->sClient;
struct timeval timeout;
dwLength=1024;
if(parent->m_ConWay==0)
listen(parent->s,SOMAXCONN);
addrlen=sizeof(parent->inaddr);
while(bRun)
{
ListenSock=parent->s;
FD_ZERO(&fdread);
FD_SET(ListenSock,&fdread);
timeout.tv_sec=0;
timeout.tv_usec=100;
if((ret=select(0,&fdread,NULL,NULL,&timeout))!=SOCKET_ERROR)
{
if(ret>0)
{
switch(parent->m_ConWay)
{
case 0:
ClientSock=accept(parent->s,(struct sockaddr*)&parent->inaddr,&addrlen);
if(ClientSock!=SOCKET_ERROR)
{
parent->sClient=ClientSock;
AcptThread=AfxBeginThread(AcceptThread,parent,THREAD_PRIORITY_NORMAL,0,
CREATE_SUSPENDED,NULL);
if(AcptThread==NULL)
{
return GetLastError();
}
else
{
bRun=TRUE;
AcptThread->ResumeThread();
return 0;
}
}
else
err=GetLastError();
break;
case 1:
ret=recv(ListenSock,(char*)buf,1024,0);
err=GetLastError();
if(ret>0)
parent->Recive((char*)buf,ret,err);
break;
case 2:
ret=recvfrom(ListenSock,(char*)buf,dwLength,0,
(struct sockaddr*)&(parent->inaddr),&addrlen);
err=GetLastError();
if(ret!=SOCKET_ERROR&&ret!=0)
{
char addr[17];
memset(addr,0,17);
memcpy(addr,parent->inaddr.sa_data,14);
//parent->Recive((char*)buf,ret,err);
parent->inform_recv(parent->m_pOwner,buf,ret,addr);
}
break;
}
}
}
}
return 1;
}


regard!

whiteclouds

QuestionRe: problem in communication with UDP Pin
Mark Salsbery20-Jul-07 6:01
Mark Salsbery20-Jul-07 6:01 
AnswerRe: problem in communication with UDP Pin
whiteclouds22-Jul-07 17:32
whiteclouds22-Jul-07 17:32 
GeneralRe: problem in communication with UDP Pin
Mark Salsbery23-Jul-07 5:02
Mark Salsbery23-Jul-07 5:02 
QuestionUTF problem Pin
Suneet.0319-Jul-07 21:52
Suneet.0319-Jul-07 21:52 
AnswerRe: UTF problem Pin
Cedric Moonen19-Jul-07 22:15
Cedric Moonen19-Jul-07 22:15 
GeneralRe: UTF problem Pin
Matthew Faithfull19-Jul-07 22:18
Matthew Faithfull19-Jul-07 22:18 
GeneralRe: UTF problem Pin
Suneet.0319-Jul-07 22:26
Suneet.0319-Jul-07 22:26 
GeneralRe: UTF problem Pin
Matthew Faithfull19-Jul-07 23:00
Matthew Faithfull19-Jul-07 23:00 
GeneralRe: UTF problem Pin
Suneet.0319-Jul-07 23:22
Suneet.0319-Jul-07 23:22 
GeneralRe: UTF problem Pin
Matthew Faithfull20-Jul-07 0:34
Matthew Faithfull20-Jul-07 0:34 
GeneralRe: UTF problem Pin
Suneet.0322-Jul-07 23:05
Suneet.0322-Jul-07 23:05 
GeneralRe: UTF problem Pin
Matthew Faithfull23-Jul-07 3:20
Matthew Faithfull23-Jul-07 3:20 
Questionusing MatchDocTypa() in mfc appln.. Pin
mirraa19-Jul-07 21:46
mirraa19-Jul-07 21:46 
QuestionPostMessage() inside MidiInProc() Pin
rp_suman19-Jul-07 21:27
rp_suman19-Jul-07 21:27 
AnswerRe: PostMessage() inside MidiInProc() Pin
Shouvik Das19-Jul-07 21:45
Shouvik Das19-Jul-07 21:45 
GeneralRe: PostMessage() inside MidiInProc() Pin
rp_suman19-Jul-07 22:20
rp_suman19-Jul-07 22:20 
AnswerRe: PostMessage() inside MidiInProc() Pin
tanvon malik19-Jul-07 21:48
tanvon malik19-Jul-07 21:48 

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.