diff --git a/src/Header Files/UDP/UDP_Client.h b/src/Header Files/UDP/UDP_Client.h new file mode 100644 index 0000000..76b3872 --- /dev/null +++ b/src/Header Files/UDP/UDP_Client.h @@ -0,0 +1,37 @@ +#ifndef __INTERCHANGE_UDP_CLIENT_H +#define __INTERCHANGE_UDP_CLIENT_H + +#include +#include +#include +#include +#include +#include //used for fprintf + +using namespace std; + +/* +* @author Arushi Rai +*/ + +class UDP_Client { +private: + char recipientAddr[32]; + queue buffer; + int udp_socket; + int PORT; + struct sockaddr_in servaddr; + + void setup(); + void bindSocket(int s, struct sockaddr_in* myaddr); + void timestamp(string* data, bool add); + bool validate(string data); //validates the buffer + string empty(); //empties buffer + +public: + UDP_Client(); + void send(); //sends the next item in the buffer, empties it as well + void addToSendBuffer(string message); +}; + +#endif \ No newline at end of file diff --git a/src/Header Files/UDP/UDP_Server.h b/src/Header Files/UDP/UDP_Server.h new file mode 100644 index 0000000..2155a7d --- /dev/null +++ b/src/Header Files/UDP/UDP_Server.h @@ -0,0 +1,34 @@ +#ifndef __INTERCHANGE_UDP_SERVER_H +#define __INTERCHANGE_UDP_SERVER_H + +#include +#include +#include +#include +#include +#include //used for fprintf + +using namespace std; + +/* +* @author Arushi Rai +*/ + +class UDP_Server { +private: + char recipientAddr[32]; + int server_socket; + int PORT; + queue buffer; + + void start(); + void timestamp(string* data, bool add); + bool validate(string data); //validates the buffer + +public: + UDP_Server(string address, int port); + void receive(); + string empty(); //empties buffer //use a more intuitive name +}; + +#endif \ No newline at end of file diff --git a/src/Header Files/UDP_Client.h b/src/Header Files/UDP_Client.h deleted file mode 100644 index 44c4cde..0000000 --- a/src/Header Files/UDP_Client.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __INTERCHANGE_UDP_CLIENT_H -#define __INTERCHANGE_UDP_CLIENT_H - -/* -* @author Arushi Rai -*/ - -#endif \ No newline at end of file diff --git a/src/Header Files/UDP_Server.h b/src/Header Files/UDP_Server.h deleted file mode 100644 index 94c96f8..0000000 --- a/src/Header Files/UDP_Server.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __INTERCHANGE_UDP_SERVER_H -#define __INTERCHANGE_UDP_SERVER_H -/* -* @author Arushi Rai -*/ -#endif \ No newline at end of file diff --git a/src/Source Files/UDP_Client.cpp b/src/Source Files/UDP/UDP_Client.cpp similarity index 100% rename from src/Source Files/UDP_Client.cpp rename to src/Source Files/UDP/UDP_Client.cpp diff --git a/src/Source Files/UDP_Server.cpp b/src/Source Files/UDP/UDP_Server.cpp similarity index 100% rename from src/Source Files/UDP_Server.cpp rename to src/Source Files/UDP/UDP_Server.cpp diff --git a/src/Source Files/UDP_Protocol.cpp b/src/Source Files/UDP_Protocol.cpp index 0b01ed1..b93ef43 100644 --- a/src/Source Files/UDP_Protocol.cpp +++ b/src/Source Files/UDP_Protocol.cpp @@ -21,5 +21,5 @@ std::string UDP_Protocol::receive() { } void UDP_Protocol::send(string message) { - client.send(message); + client.addToSendBuffer(message); } \ No newline at end of file