Home/Support/Support Forum/Does RCM6750 tcpip socket port just can connect to one device only?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Does RCM6750 tcpip socket port just can connect to one device only?

0 votes
Hi there,
I'm programming my rcm6750 and I want to use it's tcp/ip to connect to another network devices. Let say there are two network devices which is display A and display B.
Now on the rcm6750, let say its ip is 192.168.1.2 and I want to use port 2020 for the displays to connect to it.
Then can both display A and display B use the same port 2020?
Or I must assign different port to the displays like for example, display A connect to port 2020 of rcm6750 and display B connect to port 2021 of rcm6750?
asked Aug 25, 2014 in Rabbit by maniac84 New to the Community (3 points)

Please log in or register to answer this question.

1 Answer

0 votes
You can open multiple sockets using the same IP address and port. See samples\tcpip\multi_echo.c
answered Aug 25, 2014 by trooper2 Veteran of the Digi Community (589 points)
I know we can create multiple sockets.
But I want to know is, can multiple devices connect to rcm6750 using the same port number?
Or each port number in rcm6750 only limited to connect to one device only?
The answer is yes.  That is what the sample does.  See the comments at the top of the sample:  Up to 10 simultaneous connections can be established to the TCP sockets, which all listen on port ECHO_PORT (default 7).

A socket consists of the local IP and local port and the remote IP and remote port and is therefore unique.  See complete details in Chapter 3 of volume 1 of the TCPIP user manual
I see.
But from what I tested using the coding I written myself, one port in RCM6750 only can communicate with one device. For example I have device A and device B need to connect to RCM6750. I configure them to use the same port number. But the result is only one device can connect. It's like the port had been occupy by the device and only the device can communicate with the rcm6750.
What do you think is the problem here? Is it my rcm6750 coding that limited it to one device one port? How do I correct it?
Or is it it's the device A or device B that initiate this limit?
Take a look at the sample.  There must be something left out of your code.  Also, see Chapter 3 of the TCPIP user manual, volume 1.
Can you check on my socket handler routine:
void sock_handler()
{
    if (nCountSock<0 || nCountSock>=MAX_APPPORT-1)
        nCountSock=0;
    else
        nCountSock++;


    if (sockStruct[nCountSock].msDelay>MS_TIMER) return;

    sockStruct[nCountSock].msDelay=MS_TIMER;

    switch(sockStruct[nCountSock].nState)
    {
        case 0:
            printf ("listen at port %d\n", SERVER_PORTNO+nCountSock);
            tcp_listen(&sockStruct[nCountSock].tcpSock, SERVER_PORTNO+nCountSock, 0, 0, NULL, 0);
            sockStruct[nCountSock].nState = 1;
            sockStruct[nCountSock].tmLastByteRead = MS_TIMER;
            break;

        case 1:
            if(!sock_established(&sockStruct[nCountSock].tcpSock) &&
                    sock_bytesready(&sockStruct[nCountSock].tcpSock)==-1)
            {
                tcp_tick(NULL);
                if (sockStruct[nCountSock].tmLastByteRead+10000>MS_TIMER)
                    sockStruct[nCountSock].msDelay=MS_TIMER+5;
                else
                {
                    //printf ("listen timeout at port %d\n", SERVER_PORTNO+nCountSock);
                    sockStruct[nCountSock].nState = 0;
                }
            }
            else
            {
                //printf ("Connected at port %d\n", SERVER_PORTNO+nCountSock);
                ResetSockData(&sockStruct[nCountSock]);
                sockStruct[nCountSock].nState = 2;
            sockStruct[nCountSock].ulTmLastReceived = MS_TIMER;
            }
            break;

        case 2:
            if(!tcp_tick(&sockStruct[nCountSock].tcpSock) || !sock_established(&sockStruct[nCountSock].tcpSock))
            {
                //printf ("port %d closed\n", SERVER_PORTNO+nCountSock);
                sockStruct[nCountSock].nState = 0;
                //sockStruct[nCountSock].byTxDataReady = false;
                break;
            }

            sockStruct[nCountSock].msDelay=MS_TIMER+1;
            if (sockStruct[nCountSock].nProgressState==0)        // if no pending progress
            {
                sockStruct[nCountSock].nRet = ReadSockData(&sockStruct[nCountSock]);
                if (sockStruct[nCountSock].nRet==0)    // no data read
                {
                    //printf ("No data read\n");
                    if (bySynServerNow==1 && nCountSock==0)        // only server socket (master = 0) wil get syn data
                        NotifyServer(&sockStruct[nCountSock]);
                    else
                        sockStruct[nCountSock].msDelay=MS_TIMER+10;
                }
                else
                {
                    if (sockStruct[nCountSock].nRet==-1)
                        ResetSockData(&sockStruct[nCountSock]);
                }
            }
            else
                ContinueProgress(&sockStruct[nCountSock]);

            break;
    }
}

Is this function can handle multiple device using the same port number?
Is it the timeout function which I put in case 1 that causes me unable to connect multiple devices using same port number?
...