struct MiniPacket
{
int Data;
};
// init winsock code... s is socket...
MiniPacket MiniBuffer;
MiniBuffer.Data = Hello;
send(s,(char *) MiniBuffer,sizeof(MiniBuffer),0);
Is this how would you put a struct into a packet?
Packets in winsock - plz help...
If you were MEANT to understand it, we wouldn't have called it 'code'
August 09, 2002 05:33 PM
Almost ![](smile.gif)
You just need to get the address of the struct though using &
so you would do
send( s, (char*)&MiniBuffer, sizeof(MiniBuffer), 0 );
Just remember though, if you have a pointer in your struct, it will only send that 4byte pointer, and NOT the data that is being pointed to. Not sure about arrays either, i don''t think they would work though. So as long as you stick to primitives in your struct you should be ok.
![](smile.gif)
You just need to get the address of the struct though using &
so you would do
send( s, (char*)&MiniBuffer, sizeof(MiniBuffer), 0 );
Just remember though, if you have a pointer in your struct, it will only send that 4byte pointer, and NOT the data that is being pointed to. Not sure about arrays either, i don''t think they would work though. So as long as you stick to primitives in your struct you should be ok.
THANK YOU!!!!!!!!!!!!!! now it works!!!!!!
If you were MEANT to understand it, we wouldn't have called it 'code'
quote:
Original post by Anonymous Poster
Not sure about arrays either, i don''t think they would work though.
Arrays work.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
August 09, 2002 09:56 PM
Cool, thanks. I guess arrays are allocated in the same memory as the rest of the struct aren''t they. Silly me
![](smile.gif)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement