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

Method recv

src/utils/bluetooth/socket_bluetooth_linux.cpp:68–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68int SocketBluetooth::recv (char *data, int size)
69{
70 if (socket_bt < 0)
71 {
72 return -1;
73 }
74
75 fd_set set;
76 FD_ZERO (&set);
77 FD_SET (socket_bt, &set);
78 FD_SET (rep[0], &set);
79 int nfds = (socket_bt > rep[0]) ? socket_bt : rep[0];
80
81 if (pselect (nfds + 1, &set, NULL, NULL, NULL, NULL) >= 0)
82 {
83 if (FD_ISSET (socket_bt, &set))
84 {
85 int res = ::recv (socket_bt, data, size, 0);
86 for (int i = 0; i < res; i++)
87 {
88 temp_buffer.push (data[i]);
89 }
90 }
91 }
92 if ((int)temp_buffer.size () < size)
93 {
94 return 0;
95 }
96 for (int i = 0; i < size; i++)
97 {
98 data[i] = temp_buffer.front ();
99 temp_buffer.pop ();
100 }
101 return size;
102}
103
104int SocketBluetooth::close ()
105{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected