This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc3120 sl_send()和sl_recv()是否能同时使用同一个socket?

Other Parts Discussed in Thread: CC3120

请教一个问题:

我在使用cc3120模块做开发,基于network_terminal例程,在例程中tcp client发送和接收使用的都是局部变量定义的socket,示例中的使用方法是:

int32_t TCPClient(uint8_t nb, uint16_t portNumber, ip_t ipAddress, uint8_t ipv6, uint32_t numberOfPackets, uint8_t tx)
{
   int32_t sock;

   ********

   if(tx)
   {
        buflen = MAX_BUF_SIZE;
    
        /* Send packets to the server */
        status = sl_Send(sock, &buf, buflen, 0);

        ********

   }

   else

   {

         *******

         status = sl_Recv(sock, &buf, buflen, 0);

         ********

   }

}

如果我想用同一个socket,同步完成tcp接收和发送,理论上是否是可行的?

比如定义一个全局变量int32_t  gSock,在一个线程中调用sl_Send(gSock,*,*,*) 发送数据,在另一个线程中调用sl_Recv(gSock,*,*,*) 接收数据。