Click here to Skip to main content
15,893,564 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Radio Buttons Pin
_anil_13-Jun-07 15:27
_anil_13-Jun-07 15:27 
GeneralRe: Radio Buttons Pin
Akt_4_U13-Jun-07 22:53
Akt_4_U13-Jun-07 22:53 
QuestionWhat is C#? Pin
suchon_phuong13-Jun-07 7:09
suchon_phuong13-Jun-07 7:09 
AnswerRe: What is C#? Pin
David Crow13-Jun-07 7:24
David Crow13-Jun-07 7:24 
AnswerDon't answer this person. Pin
leckey13-Jun-07 7:58
leckey13-Jun-07 7:58 
AnswerRe: What is C#? Pin
Hamid_RT13-Jun-07 8:54
Hamid_RT13-Jun-07 8:54 
Questionsending data Pin
barbara_j_jenson13-Jun-07 6:38
barbara_j_jenson13-Jun-07 6:38 
AnswerRe: sending data Pin
Mark Salsbery13-Jun-07 7:03
Mark Salsbery13-Jun-07 7:03 
You could do it either way. If you know the structure of the data then a struct can be easier.

For example, following your proposed "packet header" which has an id and a length, you could make
a struct like this:
#pragma pack( push, PACKETHEADERpack, 1 )
struct PACKETHEADER
{
   unsigned char Id;;
   unsigned short Length;  <code>// <--- Byte order?</code>
};
#pragma pack( pop, PACKETHEADERpack)

Note that the structure packing is set to 1 so no padding is added to the structure or its
members.

You can then receive a header on a socket something like:
PACKETHEADER PacketHdr;
recv(socket, (char *)&PacketHdr, sizeof(PACKETHEADER), 0);

You also may need to consider byte ordering in multi-byte numeric variables. If you will be
communicating between different platforms then you may need to convert them to network byte
order, send them, then convert them to the native format on the receiving end.

Mark


"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

GeneralRe: sending data Pin
barbara_j_jenson14-Jun-07 1:29
barbara_j_jenson14-Jun-07 1:29 
Questionembedded resource in DLL v/s static library Pin
act_x13-Jun-07 6:20
act_x13-Jun-07 6:20 
AnswerRe: embedded resource in DLL v/s static library Pin
David Crow13-Jun-07 6:31
David Crow13-Jun-07 6:31 
QuestionCString concatenation problem Pin
penny black13-Jun-07 6:12
penny black13-Jun-07 6:12 
AnswerRe: CString concatenation problem Pin
Arman S.13-Jun-07 6:18
Arman S.13-Jun-07 6:18 
GeneralRe: CString concatenation problem Pin
penny black14-Jun-07 3:34
penny black14-Jun-07 3:34 
QuestionRe: CString concatenation problem Pin
David Crow13-Jun-07 6:21
David Crow13-Jun-07 6:21 
AnswerRe: CString concatenation problem Pin
penny black14-Jun-07 3:36
penny black14-Jun-07 3:36 
Questionproblem with ifstream Pin
Yonggoo13-Jun-07 5:42
Yonggoo13-Jun-07 5:42 
AnswerRe: problem with ifstream Pin
David Crow13-Jun-07 5:57
David Crow13-Jun-07 5:57 
GeneralRe: problem with ifstream(more details?) Pin
Yonggoo13-Jun-07 6:03
Yonggoo13-Jun-07 6:03 
GeneralRe: problem with ifstream(more details?) Pin
David Crow13-Jun-07 6:16
David Crow13-Jun-07 6:16 
QuestionVisual Studio debugger telling me wrong information Pin
Cyrilix13-Jun-07 5:35
Cyrilix13-Jun-07 5:35 
QuestionRe: Visual Studio debugger telling me wrong information Pin
David Crow13-Jun-07 6:19
David Crow13-Jun-07 6:19 
AnswerRe: Visual Studio debugger telling me wrong information Pin
Cyrilix13-Jun-07 6:35
Cyrilix13-Jun-07 6:35 
AnswerProblem Fixed -- optimization (/O2) causes these problems Pin
Cyrilix13-Jun-07 6:49
Cyrilix13-Jun-07 6:49 
GeneralRe: Problem Fixed -- optimization (/O2) causes these problems Pin
David Crow13-Jun-07 6:53
David Crow13-Jun-07 6: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.