File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,28 @@ impl Socket {
180
180
}
181
181
}
182
182
183
+ /// Perform a non-blocking write on the socket.
184
+ pub fn send ( & self , buf : & [ u8 ] ) -> Result < Option < usize > , Error > {
185
+ let length = buf. len ( ) ;
186
+ let ptr = buf. as_ptr ( ) ;
187
+ let result = unsafe {
188
+ sys:: nrf_send (
189
+ self . fd ,
190
+ ptr as * const _ ,
191
+ length as u32 ,
192
+ sys:: NRF_MSG_DONTWAIT as i32 ,
193
+ )
194
+ } ;
195
+ if result == -1 && get_last_error ( ) == sys:: NRF_EAGAIN as i32 {
196
+ // This is EAGAIN
197
+ Ok ( None )
198
+ } else if result < 0 {
199
+ Err ( Error :: Nordic ( "send" , result as i32 , get_last_error ( ) ) )
200
+ } else {
201
+ Ok ( Some ( result as usize ) )
202
+ }
203
+ }
204
+
183
205
/// Perform a blocking write on the socket.
184
206
pub fn write ( & self , buf : & [ u8 ] ) -> Result < usize , Error > {
185
207
let length = buf. len ( ) ;
You can’t perform that action at this time.
0 commit comments