CORDET Framework - C2 Implementation
|
Interface for the Socket-Based OutStream. More...
Go to the source code of this file.
Functions | |
void | CrFwOutStreamSocketInitAction (FwPrDesc_t prDesc) |
Initialization action for the socket-based OutStream. More... | |
void | CrFwOutStreamSocketInitCheck (FwPrDesc_t prDesc) |
Initialization check for the socket-based OutStream. More... | |
void | CrFwOutStreamSocketConfigCheck (FwPrDesc_t prDesc) |
Configuration check for the socket-based OutStream. More... | |
void | CrFwOutStreamSocketShutdownAction (FwSmDesc_t smDesc) |
Shutdown action for the socket-based OutStream. More... | |
CrFwBool_t | CrFwOutStreamSocketPcktHandover (CrFwPckt_t pckt) |
Function implementing the hand-over operation for the socket-based OutStream. More... | |
void | CrFwOutStreamSocketSetPort (unsigned short n) |
Set the port number for the socket. More... | |
Interface for the Socket-Based OutStream.
The socket-based OutStream is an OutStream (see CrFwOutStream.h
) which uses sockets to send the command and report packets. This component is built as a server socket using the Internet domain and the TCP protocol.
This component is only intended for test and demo purposes. It does not cover contingencies and has not been verified to the same level as the framework components.
This OutStream is designed to work with the Socket-Based InStream of CrFwInStreamSocket.h
which performs the function of socket client.
In its initialization process, the OutStream creates, binds and starts listening on the socket. It then spawns a threads which waits for incoming connection from a matching InStream. When the incoming connection has been accepted, the OutStream is ready to complete its configuration.
The packet hand-over operation is implemented in function CrFwOutStreamSocketPcktHandover
which performs a non-blocking write to the socket.
If the OutStream encounters an error during a system call, it uses perror
to print the error message. If the error was encountered in the initialization or configuration action, it sets the outcome of the action to 0 ("failure") and returns.
This OutStream assumes that the maximum length of a packet is smaller than 256. Compliance with this constraint is verified in the Initialization Check.
Mode of Use of a Socket-Based OutStream Component
After creation, the OutStream user must define the port number for the OutStream. This is done through function CrFwOutStreamSocketSetPort
. After this is done, the OutStream can be initialized and configured. During the initialization process, the OutStream spawns a thread which waits for its InStream to be connected to it. The OutStream can only be successfully configured after this thread has accepted the connection from the InStream.
The OutStream must complete its initialization before its InStream is initialized.
After the OutStream has completed its configuration, users can send packets to it for transmission to the InStream through calls to CrFwOutStreamSend
. If the socket connection remains open and if the rate at which send requests are made is not too high (i.e. if it does not flood the socket connection), the user can continue to make send requests. If a send request fails because the write operation to the socket has failed, the user can call CrFwOutStreamConnectionAvail
to put the OutStream back in its READY state and to attempt a resumption of the packet sending process.
This file is part of the CORDET Framework.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
For information on alternative licensing, please contact P&P Software GmbH.
Definition in file tests/CrFwOutStreamSocket.h.
void CrFwOutStreamSocketConfigCheck | ( | FwPrDesc_t | prDesc | ) |
Configuration check for the socket-based OutStream.
The check is successful if the connection from the matching InStream has been successfully accepted.
prDesc | the initialization procedure descriptor. |
Definition at line 167 of file tests/CrFwOutStreamSocket.c.
void CrFwOutStreamSocketInitAction | ( | FwPrDesc_t | prDesc | ) |
Initialization action for the socket-based OutStream.
This action:
CrFwOutStreamDefInitAction
)The function sets the outcome to "success" if all these operations are successful.
prDesc | the initialization procedure descriptor. |
Definition at line 75 of file tests/CrFwOutStreamSocket.c.
void CrFwOutStreamSocketInitCheck | ( | FwPrDesc_t | prDesc | ) |
Initialization check for the socket-based OutStream.
The check is successful if the port number has been set to a value larger than 2000.
prDesc | the initialization procedure descriptor. |
Definition at line 155 of file tests/CrFwOutStreamSocket.c.
CrFwBool_t CrFwOutStreamSocketPcktHandover | ( | CrFwPckt_t | pckt | ) |
Function implementing the hand-over operation for the socket-based OutStream.
This function performs a non-blocking write on the socket and, if it succeeds, it returns 1; otherwise, it returns 0.
pckt | the packet to be written to the socket |
Definition at line 125 of file tests/CrFwOutStreamSocket.c.
void CrFwOutStreamSocketSetPort | ( | unsigned short | n | ) |
Set the port number for the socket.
The port number must be an integer greater than 2000.
n | the port number. |
Definition at line 179 of file tests/CrFwOutStreamSocket.c.
void CrFwOutStreamSocketShutdownAction | ( | FwSmDesc_t | smDesc | ) |
Shutdown action for the socket-based OutStream.
This action executes the Shutdown Action of the base OutStream (function CrFwOutStreamDefShutdownAction
) and then closes the socket.
smDesc | the OutStream State Machine descriptor (this parameter is not used). |
Definition at line 118 of file tests/CrFwOutStreamSocket.c.