Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 30 lines (24 sloc) 0.736 kb
dd885107 » cibomahto
2012-05-24 Single port version of a c++ UDP listener.
1 #ifndef SOCKETLISTENER_H
2 #define SOCKETLISTENER_H
3
4 #include <string>
5
6 class SocketListener {
7 public:
8 /**
9 * Start a UDP server at the given address
10 * @param ip_address IP address to listen on (0.0.0.0 binds to all)
11 * @param port Port to listen on (58082 is popular)
12 */
13 void Connect(std::string ip_address, unsigned int port);
14
15 /**
16 * Get a frame of data from the socket and check that it is valid.
17 * @param frame Buffer to store the frame in.
18 * @param length Expected length of the frame.
19 * @return 0 if successful, < 0 if a failure occurred.
20 */
21 int GetFrame(char* frame, int length);
22
23 private:
24 std::string m_address;
25 unsigned int m_port;
26
27 int m_fd;
28 };
29
30 #endif
Something went wrong with that request. Please try again.