blob: 671f966ce10dca702be324c614e36f052c1a4211 [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#include "ReceiveSocket.h"
2#include <string.h>
3#include <math.h>
4#include <errno.h>
5#include <stdint.h>
6#include <stddef.h>
7
8#include "aos/common/network/SocketLibraries.h"
9#include "aos/aos_core.h"
10
11namespace aos {
12
13static const char *localhost = "0.0.0.0";
14
15int ReceiveSocket::Connect(NetworkPort port) {
16 Reset();
17 const int ret = Socket::Connect(port, localhost);
18 if (ret != 0) {
19 return ret;
20 }
21
22 if (bind(socket_, &addr_.addr,
23 sizeof(addr_)) == -1) {
24 LOG(ERROR, "failed to bind to address '%s' because of %d: %s\n", localhost,
25 errno, strerror(errno));
26 return last_ret_ = -1;
27 }
28 return last_ret_ = 0;
29}
30
31} // namespace aos
32