Project 1 - Peer-to-peer and interface protocols using C
1.0
A half-duplex layered communication system.
|
Layer 5 provides higher application layers with a mechanism for sending and receiving a simple C struct. More...
#include "layer.h"
Macros | |
#define | LAYER5_H |
#define | TSIZE 2 |
#define | RINSIZE 15 /* Bytes stored in RIN */ |
Functions | |
int | layer5_write (student *stu) |
int | layer5_read (student *stu) |
Dynamically allocate memory of the appropriate size for the firstname and lastname fields. More... | |
Layer 5 provides higher application layers with a mechanism for sending and receiving a simple C struct.
The sending function (i.e. layer5_write()) is given the address of the struct to be sent, and the corresponding call to layer5_read() in the peer will dynamically create an identical struct. Both peer processes have the definition of the struct ahead of time (compiled in), and the functions are written with this knowledge. Note that some languages (e.g. Java) have a mechanism to ensure the structures on each side match up (i.e. are the same "version" of code); we'll explore this in the future.
Peer-to-peer and Interface Protocols Using C - Layer 5
Compile with: gcc -c layer5.c -o ../build/layer5.o
int layer5_read | ( | student * | stu | ) |
Dynamically allocate memory of the appropriate size for the firstname and lastname fields.
[out] | stu | The student struct to read onto. |