Skip to content

Commit

Permalink
Set up the UDP client and server header files
Browse files Browse the repository at this point in the history
  • Loading branch information
arushirai1 committed Feb 16, 2016
1 parent dbf79b5 commit 16f2374
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 15 deletions.
37 changes: 37 additions & 0 deletions src/Header Files/UDP/UDP_Client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef __INTERCHANGE_UDP_CLIENT_H
#define __INTERCHANGE_UDP_CLIENT_H

#include <string>
#include <queue>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h> //used for fprintf

using namespace std;

/*
* @author Arushi Rai
*/

class UDP_Client {
private:
char recipientAddr[32];
queue <string> buffer;
int udp_socket;
int PORT;
struct sockaddr_in servaddr;

This comment has been minimized.

Copy link
@arushirai1

arushirai1 Feb 16, 2016

Author

Why does this show up like this on github? It was fine on my local copy...


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
34 changes: 34 additions & 0 deletions src/Header Files/UDP/UDP_Server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef __INTERCHANGE_UDP_SERVER_H
#define __INTERCHANGE_UDP_SERVER_H

#include <string>
#include <queue>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h> //used for fprintf

using namespace std;

/*
* @author Arushi Rai
*/

class UDP_Server {
private:
char recipientAddr[32];
int server_socket;
int PORT;
queue <string> 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
8 changes: 0 additions & 8 deletions src/Header Files/UDP_Client.h

This file was deleted.

6 changes: 0 additions & 6 deletions src/Header Files/UDP_Server.h

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Source Files/UDP_Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ std::string UDP_Protocol::receive() {
}

void UDP_Protocol::send(string message) {
client.send(message);
client.addToSendBuffer(message);
}

0 comments on commit 16f2374

Please sign in to comment.