Hi all,
I'm learning socket programming in Unix. My jobs is sending some frames over TCP/IP Client-Server model, ex Hello, Ack, Bye packets. Each frames have a ID field, which helps we know which packet the server/client received. For example, 1 for Hello, 2 for Ack and 3 for Bye. I use struct in C to create frames, one struct per frame, so I have 3 structs: Hello, Ack and Byte for both Client and Server. But I got a problem. How the receiver know which packet it receive ?
widapol
0
Newbie Poster
Recommended Answers
Jump to PostHave the server check the packet ID field and it will know which packet its getting. Hopefully the ID field is the first item in the packet to make it easier for the programs to reconstruct the appropriate structure.
For example the client would read the first byte from …
Jump to PostMove the ID field to the first field in the packet.
struct { int32_t msgId; // ID of packet int32_t msgLen; char Preamble[11]; char senderId[50]; // email of sender } helloMsg;
>>How can I check first byte of TCP stream to identify the kind of frames that …
All 8 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
widapol
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
widapol
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
widapol
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
widapol
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.