Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 OpenUAS
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef DIGITAL_CAM_USHER_SOCKET_H
19#define DIGITAL_CAM_USHER_SOCKET_H
20
21/**
22 * @file socket.h
23 * @brief Local non-blocking UDP channel used by USHER's development pipeline.
24 * @details This is intentionally loopback-only infrastructure for local SODA and
25 * simulator integration, not a network-facing control protocol.
26 */
27
28/** @brief Create the loopback UDP endpoint and, for a server, claim USHER ownership.
29 * @param is_server Nonzero to bind the fixed local port; zero for an unbound sender.
30 * @return 0 on success, or -1 on failure; EALREADY preserves an active endpoint.
31 * @details The server bind doubles as the physical-mode single-instance claim.
32 * A second USHER must fail rather than share the port because it would also
33 * compete for the same UART and camera resources. */
34int socket_init(int is_server);
35/** @brief Close the owned UDP endpoint; repeated calls are harmless. */
36void socket_deinit(void);
37/** @brief Return the active UDP descriptor for polling.
38 * @return Borrowed descriptor, or a negative value before initialization/after teardown. */
39int socket_get_fd(void);
40/** @brief Receive one datagram without blocking.
41 * @param buffer Destination bytes.
42 * @param len Destination capacity.
43 * @return recvfrom() result, including -1/EAGAIN when no datagram is ready. */
44int socket_recv(char *buffer, int len);
45/** @brief Send one loopback datagram without blocking.
46 * @param buffer Payload bytes.
47 * @param len Payload length. */
48void socket_send(char *buffer, int len);
49
50#endif /* DIGITAL_CAM_USHER_SOCKET_H */
int socket_get_fd(void)
Return the active UDP descriptor for polling.
Definition socket.c:102
int socket_recv(char *buffer, int len)
Receive one datagram without blocking.
Definition socket.c:107
int socket_init(int is_server)
Create the loopback UDP endpoint and, for a server, claim USHER ownership.
Definition socket.c:44
void socket_deinit(void)
Close the owned UDP endpoint; repeated calls are harmless.
Definition socket.c:96
void socket_send(char *buffer, int len)
Send one loopback datagram without blocking.
Definition socket.c:126