|  | F´ Flight Software - C/C++ Documentation
    NASA-v1.6.0
    A framework for building embedded system applications to NASA flight quality standards. | 
 
 
 
Go to the documentation of this file.
   14 #include <Fw/Types/BasicTypes.hpp> 
   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, 
nullptr, 
nullptr)) < 0) {
 
  
 
void close()
closes the socket
@ SOCK_FAILED_TO_SET_SOCKET_OPTIONS
Failed to configure socket.
SocketIpStatus startup()
Opens the server socket and listens, does not block.
SocketIpStatus setupTimeouts(NATIVE_INT_TYPE socketFd)
setup the socket timeout properties of the opened outgoing socket
Helper base-class for setting up Berkley sockets.
@ SOCK_FAILED_TO_ACCEPT
Failed to accept connection.
TcpServerSocket()
Constructor for client socket tcp implementation.
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_INVALID_IP_ADDRESS
Bad IP address supplied.
@ SOCK_SUCCESS
Socket operation successful.
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)
void shutdown()
Shutdown client socket, and listening server socket.
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.
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.
@ SOCK_FAILED_TO_GET_SOCKET
Socket open failed.
U16 m_port
IP address port used.