Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCListCtrl SortGroups by name Pin
Abinash Mohanty4-Apr-10 23:14
Abinash Mohanty4-Apr-10 23:14 
AnswerRe: CListCtrl SortGroups by name Pin
David Crow2-Jan-11 15:01
David Crow2-Jan-11 15:01 
QuestionC++ socket and thread [modified] Pin
canard294-Apr-10 22:29
canard294-Apr-10 22:29 
AnswerRe: C++ socket and thread Pin
Moak4-Apr-10 23:29
Moak4-Apr-10 23:29 
GeneralRe: C++ socket and thread Pin
canard295-Apr-10 2:14
canard295-Apr-10 2:14 
GeneralRe: C++ socket and thread Pin
Moak5-Apr-10 3:04
Moak5-Apr-10 3:04 
GeneralRe: C++ socket and thread Pin
canard295-Apr-10 4:47
canard295-Apr-10 4:47 
GeneralRe: C++ socket and thread Pin
Moak5-Apr-10 8:25
Moak5-Apr-10 8:25 
Okay thanks for the formatting! Smile | :)

Let my try to help.... put the loop around the blocking part (pseudocode):

socket();
bind();
for(;;)
{
	recvfrom();
	if(ok) ExecuteCommand();
}
closesocket();



Right now the worker thread has no exit condition, you probably want to add one in order to avoid terminating the thread the hard way at application exit. Also have a look at some other issues, e.g. starting from this line

nb_caracters=recvfrom(socket_recevoir,buffer,1515,0,(struct sockaddr*)&information_recevoir,&tempo);

should become something like
int nb_caracters = recvfrom(socket_recevoir, buffer, sizeof(buffer)-1, 0, (struct sockaddr*)&information_recevoir, &tempo);
if(nb_caracters > 0) 				//data was received and no socket error (return value -1)?
{
	buffer[nb_caracters] = 0;		//one byte was reserved for terminating Null
	ExecuteCommand(buffer, NULL, 0);	//lets hope it was a complete package and also not a duplicate
}


Webchat in Europe Java | [Coffee] Now with 26% more Twitter

modified on Monday, April 5, 2010 3:34 PM

QuestionListview row color Pin
arun_pk4-Apr-10 22:26
arun_pk4-Apr-10 22:26 
AnswerRe: Listview row color Pin
Code-o-mat5-Apr-10 0:30
Code-o-mat5-Apr-10 0:30 
AnswerRe: Listview row color Pin
Rolf Kristensen12-Apr-10 9:33
Rolf Kristensen12-Apr-10 9:33 
Questionerror C2440 Pin
MsmVc4-Apr-10 21:28
MsmVc4-Apr-10 21:28 
AnswerRe: error C2440 Pin
Adam Roderick J4-Apr-10 21:35
Adam Roderick J4-Apr-10 21:35 
GeneralRe: error C2440 Pin
MsmVc4-Apr-10 21:55
MsmVc4-Apr-10 21:55 
GeneralRe: error C2440 Pin
Adam Roderick J4-Apr-10 22:00
Adam Roderick J4-Apr-10 22:00 
GeneralRe: error C2440 Pin
MsmVc4-Apr-10 22:06
MsmVc4-Apr-10 22:06 
GeneralRe: error C2440 Pin
Adam Roderick J4-Apr-10 22:21
Adam Roderick J4-Apr-10 22:21 
GeneralRe: error C2440 Pin
MsmVc4-Apr-10 22:31
MsmVc4-Apr-10 22:31 
GeneralRe: error C2440 Pin
Game-point4-Apr-10 22:45
Game-point4-Apr-10 22:45 
GeneralRe: error C2440 Pin
MsmVc4-Apr-10 23:11
MsmVc4-Apr-10 23:11 
GeneralRe: error C2440 Pin
Emilio Garavaglia5-Apr-10 21:04
Emilio Garavaglia5-Apr-10 21:04 
GeneralRe: error C2440 Pin
MsmVc5-Apr-10 21:12
MsmVc5-Apr-10 21:12 
GeneralRe: error C2440 Pin
Emilio Garavaglia5-Apr-10 21:46
Emilio Garavaglia5-Apr-10 21:46 
GeneralRe: error C2440 Pin
MsmVc5-Apr-10 22:00
MsmVc5-Apr-10 22:00 
GeneralRe: error C2440 Pin
Emilio Garavaglia5-Apr-10 22:10
Emilio Garavaglia5-Apr-10 22:10 

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.