Wip_cerr_not_supported


#1

Hi

I create TCP server :
ServerOrClient_socket = wip_TCPServerCreateOpts( (u16)wm_atoi(“12345”), TCP_Server_Events_Handler , NULL,
WIP_COPT_SND_BUFSIZE, TCP_Snd_BufSize, WIP_COPT_RCV_BUFSIZE, TCP_Rcv_BufSize,
WIP_COPT_SND_LOWAT, 0x1, WIP_COPT_RCV_LOWAT, 0x1 , WIP_COPT_END );
if (ServerOrClient_socket == NULL){ SEND_TECHNOLOGIES_MESSAGE(“TCP_SERVER_CREATE…ERROR\r\n” );}
else {SEND_TECHNOLOGIES_MESSAGE(“TCP_SERVER_START…OK\r\n” );}

==================================================
in Handler:

void TCP_Server_Events_Handler ( wip_event_t *TCP_server_events, void *ctx )
{
char * receive_data;
u32 receive_data_len, i;
u8 remuin_len;
int Temp;
char buf[100];

char TCP_Recv_Buff[0x400];
s16 Real_Write_Data_Len;
// u16 i;
u32 Before_Start_Buff, Volume_Byte_for_Write, Data_No_Writed;

switch(TCP_server_events->kind)
{
case WIP_CEV_OPEN: SEND_TECHNOLOGIES_MESSAGE(“WIP_CEV_OPEN\r\n” ); break;
case WIP_CEV_READ:
{
if(!REM_uin_receive) // Если идентификатор еще не получен
{
receive_data_len = TCP_server_events->content.read.readable;

      wm_sprintf( buf, "*Receive volume data:  %d*\r\n", receive_data_len);
      adl_atSendResponse( ADL_AT_RSP, buf );
     
      receive_data = adl_memGet(receive_data_len+1);
      
       if(receive_data_len == 20)
        {
        Temp  =  wip_read(ServerOrClient_socket,receive_data,(receive_data_len+1));//+1));
        wm_sprintf( buf, "*Real_data_len:  %d*\r\n", Temp);
        adl_atSendResponse( ADL_AT_RSP, buf );

.
.
.

Temp = WIP_CERR_NOT_SUPPORTED, why ???
When I read wip_read(ServerOrClient_socket,receive_data,(receive_data_len+1));
receive_data consist not right chars.

Thank you!


#2

The logic of your code is not obvious, it’s hard to tell what you’re trying to do.

A server socket (wip_TCPServerCreate(port, evh, ctx)) does not communicate directly. Instead, whenever it receives a connection request from the network, it creates a new communication socket, and this new socket will be able to read/write data. You’re notified that this socket has been created because the event handler evh receives a WIP_CEV_OPEN event, with ev->channel set to the new client socket. This new socket can read/write, but the server still can’t and never will.

I suggest you get rid of that puzzling “clientOrServerSocket” variable, and work with two separate variables, one for the server, one for the communication socket. That is, if you’re sure that you’ll never want to handle several connections simultaneously. If you might, then you need to rework your application accordingly.