Project 1 - Peer-to-peer and interface protocols using C  1.0
A half-duplex layered communication system.
 All Classes Files Functions Macros
Macros | Functions
layer5.c File Reference

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...
 

Detailed Description

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

Author
Nicholas Guthrie guthr.nosp@m.n@rp.nosp@m.i.edu http//nickguthrie.com January 30, 2014

Compile with: gcc -c layer5.c -o ../build/layer5.o

Function Documentation

int layer5_read ( student stu)

Dynamically allocate memory of the appropriate size for the firstname and lastname fields.

Warning
It is the responsibility of the caller to free this memory.
Parameters
[out]stuThe student struct to read onto.
Returns
The return value is 1 on success, or -1 on error.