Developer Portal Community

    Showing results for 
    Search instead for 
    Did you mean: 


    Occasional Visitor


    Has anyone successfully used the Serval XTcp server to allow tcp connections to the XDK ? In a test implementation I started a listener on port 9999 and when I checked, the port was open, however when connecting (python script) and sending data I didn't see either the appSendCallback or the appRecvCallback function call (nothing from those functions was printed to the console). The port also was closed after the first connection.

    Relevant code:

    void appReceiveCallback(uint8_t sessionId, Msg_T *msg_ptr, retcode_t status) {
    	printf("appReceiveCallback entered \r\n");
    	//Get peer information from the message pointed
    	Ip_Address_T peerIpAddress;
    	uint16_t peerPort;
    	char peerIpAddressString[15];
    	Retcode_T rc = RETCODE_OK;
    	XTcp_getPeer(msg_ptr, &peerIpAddress, &peerPort);
    	// Convert address to string
    	rc = Ip_convertAddrToString(&peerIpAddress, peerIpAddressString);
    	if (0 > rc) {
    		printf("IP conversion to string has failed! \r\n");
    	printf("[TCE] : Peer IP is : %s:%d\r\n", peerIpAddressString, peerPort);
    void appSendCallback(uint8_t sessionId, Msg_T *msg_ptr, retcode_t status) {
    	printf("Entered appSendCallback");
    void AppController_Init(void * cmdProcessorHandle, uint32_t param2)
        Retcode_T retcode = RETCODE_OK;
        if (cmdProcessorHandle == NULL)
            printf("AppController_Init : Command processor handle is NULL \r\n");
            AppCmdProcessor = (CmdProcessor_T *) cmdProcessorHandle;
            retcode = CmdProcessor_Enqueue(AppCmdProcessor, AppControllerSetup, NULL, UINT32_C(0));
        if (RETCODE_OK != retcode)
            assert(0); /* To provide LED indication for the user */
        WlanConnect_SSID_T connectSSID = (WlanConnect_SSID_T) "SSID";
        WlanConnect_PassPhrase_T connectPassPhrase = (WlanConnect_PassPhrase_T) "passphrase";
        WlanConnect_WPA(connectSSID, connectPassPhrase, NULL);
        if (RC_OK != XTcpServer_initialize()) {
        	printf("XTcp initialization failure \r\n");
        Ip_Port_T serverPort = Ip_convertIntToPort(9999);
        // Start TCP Server
        if (RC_OK == XTcpServer_listen(serverPort, appSendCallback, appReceiveCallback)) {
        	printf("TCP Server Started...\r\n");
        else {
        	printf("TCP Server Not Started!\r\n");


    2 REPLIES 2
    Community Manager
    Community Manager

    Re: XTcpServer

    Hi willsonnate1, thanks for your question to the community, we'll also check with some xdk experts to see if they have any input!

    New Poster

    Re: XTcpServer

    Hello willsonnate1,

    I have not explored the Serval XTcp Server yet. But then again, since XTcp is proprietary protocol, I would suggest you to make use of another device which runs the Serval XTcp Client to connect to the server rather than using the python script. Please note that the stack also suggest to provide proper initial delay after initiating connection to the server, as connection will not be opened immediately. The three-way handshake needs to be completed first. Will this be taken care in your python script ?

    Once if using the XTcp Client also doesn't take you further,  I would suggest you to make sure whether the AppControllerSetup is getting executed properly before starting with WlanConnect_Init().

    If still the problem persists, please feel free to post further details as it would be quite interesting to look further.