CORDET Framework - C2 Implementation
CrFwOutStreamSocket.c File Reference

Implementation of Socket-Based OutStream. More...

Go to the source code of this file.

Functions

static void * acceptThreadEntry (void *ptr)
 Entry point for the thread which waits for the incoming connection from the InStream. More...
 
void CrFwOutStreamSocketInitAction (FwPrDesc_t prDesc)
 Initialization action 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 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 CrFwOutStreamSocketSetPort (unsigned short n)
 Set the port number for the socket. More...
 

Variables

static unsigned short portno = 0
 Set the port number (must be same as the port number specified in CrFwOutStreamSocket.c
 
static int sockfd
 The file descriptors for the socket.
 
static int newsockfd
 The file descriptors for the socket.
 
static struct sockaddr_in cli_addr
 Socket variable.
 
static socklen_t clilen
 Socket variable.
 

Detailed Description

Implementation of Socket-Based OutStream.

Author
Vaclav Cechticky vacla.nosp@m.v.ce.nosp@m.chtic.nosp@m.ky@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m
Alessandro Pasetti paset.nosp@m.ti@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m

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 CrFwOutStreamSocket.c.

Function Documentation

static void * acceptThreadEntry ( void *  ptr)
static

Entry point for the thread which waits for the incoming connection from the InStream.

Parameters
ptrunused argument (required with compatibility with pthread create function)

Definition at line 143 of file CrFwOutStreamSocket.c.

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.

Parameters
prDescthe initialization procedure descriptor.

Definition at line 167 of file CrFwOutStreamSocket.c.

void CrFwOutStreamSocketInitAction ( FwPrDesc_t  prDesc)

Initialization action for the socket-based OutStream.

This action:

  • creates and binds the socket
  • start listening on the socket
  • spawns a thread which waits for an incoming connection from a matching InStream
  • execute the Initialization Action of the base OutStream (function CrFwOutStreamDefInitAction)

The function sets the outcome to "success" if all these operations are successful.

Parameters
prDescthe initialization procedure descriptor.

Definition at line 75 of file 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.

Parameters
prDescthe initialization procedure descriptor.

Definition at line 155 of file 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.

Parameters
pcktthe packet to be written to the socket
Returns
1 if the packet was successfully written to the socket; 0 otherwise.

Definition at line 125 of file CrFwOutStreamSocket.c.

void CrFwOutStreamSocketSetPort ( unsigned short  n)

Set the port number for the socket.

The port number must be an integer greater than 2000.

Parameters
nthe port number.

Definition at line 179 of file 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.

Parameters
smDescthe OutStream State Machine descriptor (this parameter is not used).

Definition at line 118 of file CrFwOutStreamSocket.c.

P&P Software GmbH, Copyright 2012-2013, All Rights Reserved