XDK API  3.6.0
Documentation
Functions
Serval_XTcpServer.h File Reference

The interface description of a proprietary TCP Server based application protocol. More...

#include <Serval_Defines.h>
#include <Serval_Types.h>
#include <Serval_XTcp.h>
#include <Serval_Callable.h>
#include <Serval_Tcp.h>
+ Include dependency graph for Serval_XTcpServer.h:

Functions

retcode_t XTcpServer_initialize (void)
 Initializes the XTCP server including all needed used modules. More...
 
retcode_t XTcpServer_listen (Ip_Port_T serverPort, AppXTcpCallback_T appSndCallback, AppXTcpCallback_T appRcvCallback)
 This function opens a port and registers a handling function for this port. More...
 
retcode_t XTcpServer_unlisten (Ip_Port_T port)
 This function stops an active TCP Server. When TCP Server is enabled, this function stops the listening by deleting the socket. After invoking this function the socket used by this module is invalid, and must not be used for any further communication unless reinitialized. More...
 

Detailed Description

Since
1.4

Function Documentation

retcode_t XTcpServer_initialize ( void  )
Return values
RC_OKon successful
RC_XTCP_SERVER_INIT_ERRORif an error occurs while initializing the XTcp Server
Example
Initialize an XTcp Server
1 // Initialize a TCP Server
2 if (RC_OK != XTcpServer_initialize())
3 {
4  printf("Util and xTCP initialization failure!\n\r");
5 }
retcode_t XTcpServer_listen ( Ip_Port_T  serverPort,
AppXTcpCallback_T  appSndCallback,
AppXTcpCallback_T  appRcvCallback 
)
Parameters
[in]serverPortTCP Server secure port to listen on
[in]appSndCallbackCallback function for Send data
[in]appRcvCallbackCallback function for Received data
Return values
RC_OKon success
RC_XTCP_LISTEN_ERRORif the TCP Server was not started correctly.
Example
Start a TCP Server listener
1 Ip_Port_T serverPort = Ip_convertIntToPort(9999);
2 
3 // Start a TCP Server
4 if (RC_OK == XTcpServer_listen(serverPort, appSendCallback, appReceiveCallback))
5 {
6  printf("TCP Server Started...\n\r");
7 }
8 else
9 {
10  printf("TCP Server not started!\n\r");
11 }
See also
XTcpClient_connect()
retcode_t XTcpServer_unlisten ( Ip_Port_T  port)
Parameters
[in]portServer Port to be unlisten
Return values
RC_OKon success
RC_XTCP_LISTEN_ERRORif the listener to be closed is invalid or close function fails
Example
Stop a TCP Server (unlisten)
1 Ip_Port_T serverPort1 = Ip_convertIntToPort(9999);
2 
3 // Close a TCP Server
4 if (RC_OK == XTcpServer_unlisten(serverPort1))
5 {
6  printf("TCP Server was stopped ...\n\r");
7 }
8 else
9 {
10  printf("TCP Server was not stopped!\n\r");
11 }

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:46 by doxygen 1.8.8