FactbirdHQ / ublox-short-range-rs

A driver crate for the entire u-blox short range family in Rust
6 stars 2 forks source link

Always initiating handles to 0 causes blocks #31

Closed unizippro closed 2 years ago

unizippro commented 2 years ago

Only one unconnected socket can exist in the socket set at any one time. Since the socket set checks for dublicate socket handles.

Example:

161642 DEBUG [TCP] Opening socket
161643 DEBUG Adding socket! 0 Tcp
161643 DEBUG [Socket Set] Adding to: [(Handle(0), Tcp(State::Created)), (Handle(2), Tcp(State::Connected)), (Handle(4), Tcp(State::Connected))]
161644 ERROR [TCP] Opening socket Error: DuplicateSocket

Solution

Decouble Peer handles and socket handles, in the same way peer handle and channel id is set up.

Alternative

Create increasing "first" socket handles. This is quite an easy fix. Great care should be taken as to not overlap with the peer handles gotten back from the modem. Another way would be eliminating the need for actually allocating anything upon creation of the socket, but then the "right of way" is moved onto the client connecting their socket first.