Project 1 - Peer-to-peer and interface protocols using C
1.0
A half-duplex layered communication system.
|
Layer 3 provides the capability to send and receive messages, where a message is defined as any sequence of bytes. More...
#include "layer.h"
Functions | |
int | layer3_write (char *msg, int len) |
Sends a message. More... | |
int | layer3_read (char *msg, int max) |
reads a message and stores it in memory starting at the address specified by msg More... | |
Layer 3 provides the capability to send and receive messages, where a message is defined as any sequence of bytes.
More specifically, there is no length limitation at layer 3, so a sender can ask layer 3 to send any size message.
Peer-to-peer and Interface Protocols Using C
Compile with: gcc -c layer3.c -o ../build/layer3.o
int layer3_read | ( | char * | msg, |
int | max | ||
) |
reads a message and stores it in memory starting at the address specified by msg
[in] | msg | Where the message that is read is stored. |
[in] | max | No more than max bytes will be put into memory, so max must limit the size of the message read. |
If a message is received by layer3_read() that would require more than max bytes, layer3_read() must return -1 (indicating an error).
int layer3_write | ( | char * | msg, |
int | len | ||
) |
Sends a message.
[in] | msg | A message of any length to send. |
[in] | len | The size of the message to send. |