34 lines
660 B
C
34 lines
660 B
C
#ifndef SOCKET_H
|
|
#define SOCKET_H
|
|
|
|
#define MAX_DATA_SIZE 2048
|
|
|
|
/**
|
|
* void recv_message
|
|
*
|
|
* int sfd - The socket to use
|
|
* char** message - The EMPTY buffer we're using
|
|
*
|
|
* Receives the message and malloc's the buffer to store the message
|
|
*
|
|
* Result must be free'd
|
|
*/
|
|
void recv_message(int sfd, char** message);
|
|
|
|
/**
|
|
* void send_message
|
|
*
|
|
* int sfd - The socket to use
|
|
* char* message - The message we're sending
|
|
*
|
|
* Sends the message to the socket
|
|
*/
|
|
void send_message(int sfd, char* message);
|
|
|
|
/**
|
|
* A simple macro that simplifies the usage of recv_message
|
|
*/
|
|
#define DO_MSG_RECV(sfd, buf) recv_message(sfd, &buf);puts(buf);free(buf)
|
|
|
|
#endif
|