MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / recv

Method recv

src/utils/bluetooth/socket_bluetooth_win.cpp:90–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90int SocketBluetooth::recv (char *data, int size)
91{
92 if (socket_bt == INVALID_SOCKET)
93 {
94 return -1;
95 }
96 fd_set set;
97 FD_ZERO (&set);
98 FD_SET (socket_bt, &set);
99
100 timeval timeout {0, 0};
101 if (select (1, &set, nullptr, nullptr, &timeout) >= 0)
102 {
103 if (FD_ISSET (socket_bt, &set))
104 {
105 int res = ::recv (socket_bt, data, size, 0);
106 for (int i = 0; i < res; i++)
107 {
108 temp_buffer.push (data[i]);
109 }
110 }
111 }
112 if ((int)temp_buffer.size () < size)
113 {
114 return 0;
115 }
116 for (int i = 0; i < size; i++)
117 {
118 data[i] = temp_buffer.front ();
119 temp_buffer.pop ();
120 }
121 return size;
122}
123
124int SocketBluetooth::close ()
125{

Callers 1

bluetooth_get_dataFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected