30 const U32 send_timeout_seconds,
31 const U32 send_timeout_microseconds,
37 m_allocation_size = buffer_size;
39 (void)m_socket.
configure(hostname, port, send_timeout_seconds, send_timeout_microseconds);
58 return allocate_out(0,
static_cast<U32
>(m_allocation_size));
72 this->
recv_out(0, buffer, recvStatus);
PlatformIntType NATIVE_INT_TYPE
PlatformAssertArgType FwAssertArgType
PlatformSizeType FwSizeType
C++-compatible configuration header for fprime configuration.
static const Fw::TimeInterval SOCKET_RETRY_INTERVAL
Helper base-class for setting up Berkeley sockets.
SocketIpStatus configure(const char *hostname, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds)
configure the ip socket with host and transmission timeouts
Status associated with the received data.
@ RECV_OK
Receive worked as expected.
@ RECV_ERROR
Receive error occurred retrying may succeed.
@ RECV_NO_DATA
Receive worked, but there was no data.
Status returned by the send call.
@ SEND_ERROR
Send error occurred retrying may succeed.
@ SEND_RETRY
Data send should be retried.
@ SEND_OK
Send worked as expected.
SocketDescriptor m_descriptor
bool m_reconnect
Force reconnection.
virtual void readLoop()
receive off the TCP socket
SocketIpStatus send(const U8 *const data, const U32 size)
send data to the IP socket from the given buffer
bool running()
is the read loop running
Auto-generated base for TcpServer component.
void ready_out(FwIndexType portNum)
Invoke output port ready.
void deallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port deallocate.
Fw::Buffer allocate_out(FwIndexType portNum, U32 size)
Invoke output port allocate.
void recv_out(FwIndexType portNum, Fw::Buffer &recvBuffer, const Drv::RecvStatus &recvStatus)
Invoke output port recv.
bool isConnected_ready_OutputPort(FwIndexType portNum)
~TcpServerComponentImpl()
Destroy the component.
SocketIpStatus startup()
startup the server socket for communications
void connected() override
called when the IPv4 system has been connected
U16 getListenPort()
get the port being listened on
void terminate()
terminate the server socket
SocketIpStatus configure(const char *hostname, const U16 port, const U32 send_timeout_seconds=SOCKET_SEND_TIMEOUT_SECONDS, const U32 send_timeout_microseconds=SOCKET_SEND_TIMEOUT_MICROSECONDS, FwSizeType buffer_size=1024)
Configures the TcpServer settings but does not open the connection.
IpSocket & getSocketHandler() override
returns a reference to the socket handler
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override
sends a buffer to be filled with data
bool isStarted()
is started
void readLoop() override
read from the socket, overridden to start and terminate the server socket
TcpServerComponentImpl(const char *const compName)
construct the TcpServer component.
Fw::Buffer getBuffer() override
returns a buffer to fill with data
SocketIpStatus startup(SocketDescriptor &socketDescriptor)
Opens the server socket and listens, does not block.
U16 getListenPort()
get the port being listened on
void terminate(const SocketDescriptor &socketDescriptor)
close the server socket created by the startup call
static void log(const char *format,...)
log a formated string with supplied arguments
locks a mutex within the current scope
static Status delay(Fw::TimeInterval interval)
delay the current task
SocketIpStatus
Status enumeration for socket return values.
@ SOCK_SUCCESS
Socket operation successful.
@ SOCK_INTERRUPTED_TRY_AGAIN
Interrupted status for retries.
@ SOCK_NO_DATA_AVAILABLE
No data available or read operation would block.
@ SOCK_NOT_STARTED
Socket has not been started.
PlatformIntType serverFd
Used for server sockets to track the listening file descriptor.