 |
F´ Flight Software - C/C++ Documentation
NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
|
Go to the documentation of this file.
17 #ifdef TGT_OS_TYPE_VXWORKS
29 #elif defined TGT_OS_TYPE_LINUX || TGT_OS_TYPE_DARWIN
30 #include <sys/socket.h>
32 #include <arpa/inet.h>
34 #error OS not supported for IP Socket Communications
45 struct sockaddr_in address;
49 if ((serverFd = ::socket(AF_INET, SOCK_STREAM, 0)) == -1) {
53 address.sin_family = AF_INET;
54 address.sin_port = htons(this->
m_port);
57 #if defined TGT_OS_TYPE_VXWORKS || TGT_OS_TYPE_DARWIN
58 address.sin_len =
static_cast<U8>(
sizeof(
struct sockaddr_in));
67 if (::bind(serverFd,
reinterpret_cast<struct sockaddr*
>(&address),
sizeof(address)) < 0) {
74 if (::listen(serverFd, 0) < 0) {
82 (void)::
shutdown(this->m_base_fd, SHUT_RDWR);
83 (void)::
close(this->m_base_fd);
91 if ((clientFd = ::accept(m_base_fd,
NULL,
NULL)) < 0) {
@ SOCK_SUCCESS
Socket operation successful.
@ SOCK_FAILED_TO_SET_SOCKET_OPTIONS
Failed to configure socket.
SocketIpStatus setupTimeouts(NATIVE_INT_TYPE socketFd)
setup the socket timeout properties of the opened outgoing socket
uint8_t U8
8-bit unsigned integer
Helper base-class for setting up Berkley sockets.
@ SOCK_FAILED_TO_ACCEPT
Failed to accept connection.
TcpServerSocket()
Constructor for client socket tcp implementation.
@ SOCK_INVALID_IP_ADDRESS
Bad IP address supplied.
char m_hostname[SOCKET_MAX_HOSTNAME_SIZE]
Hostname to supply.
I32 sendProtocol(const U8 *const data, const U32 size)
Protocol specific implementation of send. Called directly with retry from send.
@ SOCK_FAILED_TO_LISTEN
Failed to listen on socket.
@ SOCK_FAILED_TO_GET_SOCKET
Socket open failed.
SocketIpStatus startup(void)
Opens the server socket and listens, does not block.
void shutdown(void)
Shutdown client socket, and listening server socket.
I32 recvProtocol(U8 *const data, const U32 size)
Protocol specific implementation of recv. Called directly with error handling from recv.
static void logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
SocketIpStatus openProtocol(NATIVE_INT_TYPE &fd)
Tcp specific implementation for opening a client socket connected to this server.
SocketIpStatus
Status enumeration for socket return values.
@ SOCK_FAILED_TO_BIND
Failed to bind to socket.
Declares ISF basic types.
static SocketIpStatus addressToIp4(const char *address, void *ip4)
converts a given address in dot form x.x.x.x to an ip address. ONLY works for IPv4.
U16 m_port
IP address port used.
int NATIVE_INT_TYPE
native integer type declaration
void close(void)
closes the socket