diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-21 00:12:02 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-21 00:12:02 +0200 |
commit | d4e7c6876eed2733a2678668bdcabdd87659e826 (patch) | |
tree | 5943038b081f7392182542fc62b2ba2a9f8619bc /common.h | |
parent | f6eef73f7f0e805811bb9c2d748c17d558615a74 (diff) |
Added common code for messages
- add: send_message, receive_message functions
- change: use u8, u16, u32, where possible
- fix: use PORT in server.c
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -39,3 +39,11 @@ u8 save_message(struct message *msg, FILE *f); // load the message msg from file f, returns zero on success, returns 1 if the msg.text // was empty which should not be allowed. u8 load_message(struct message *msg, FILE *f); + +// Send a stream of bytes containing msg +// return -1 if send() returns -1. Otherwise returns number of bytes sent. +u32 send_message(struct message msg, u32 serverfd); +// Receives a stream of bytes and populates msg with the data received +// if recv() returns 0 or -1 it will return early and return 0 or -1 accordingly. +// Otherwise returns the number of bytes received +u32 receive_message(struct message *msg, u32 clientfd); |