Read data from Server socket

The problem consists in that that, when opening socket the server and client connection implementation with PC. WIP_CEV_OPEN and WIP_CEV_WRITE events are created. A field of it I with PC send data and I see that WIP_CEV_READ event in the processor is created I read wip_read this by means of the command but I receive error state number -999 WIP_CERR_CSTATE. I ask to prompt the possible reasons of such behavior. the part of a code is provided below.

static wip_channel_t socket0S = NULL;

void evh_tcp_server( wip_event_t *ev, void *ctx) {

wip_channel_t c = ev->channel;
int nread = 0;
switch ( ev->kind )
    {
        case WIP_CEV_OPEN:
        	adl_atSendResponse ( ADL_AT_UNS,"\r\n Server_WIP_CEV_OPEN");
        	 break;
        case WIP_CEV_READ:
        {
        	adl_atSendResponse ( ADL_AT_UNS,"\r\n Server_WIP_CEV_READ");

        		

        	nread = wip_read ( c, rcv_buffer, sizeof ( rcv_buffer ) );
        	if(nread > 0) {adl_atSendResponse ( ADL_AT_UNS,"\r\n Read Data from Buf Socket0S");  wm_sprintf_U32_((u32) nread);}
        	if(nread < 0)
        	{
        		adl_atSendResponse ( ADL_AT_UNS,"\r\n Read Data error code Socket0S");
        		wm_sprintf_U32_((u32) nread);	        		
        	}
        	if(nread == 0){adl_atSendResponse ( ADL_AT_UNS,"\r\n Read Data error nread == 0"); wm_sprintf_U32_((u32) nread);}
            break;
        }

        case WIP_CEV_WRITE:
        {
        	adl_atSendResponse ( ADL_AT_UNS,"\r\n Server_WIP_CEV_WRITE");
        	//nwrite = wip_write ( ev->channel, snd_buffer, sizeof ( snd_buffer ) );
            break;
        }

        case WIP_CEV_ERROR:
        {
        	adl_atSendResponse ( ADL_AT_UNS,"\r\n Server_WIP_CEV_ERROR");
            break;
        }

        case WIP_CEV_PEER_CLOSE:
        {
        	adl_atSendResponse ( ADL_AT_UNS,"\r\n Server_WIP_CEV_PEER_CLOSE");
            break;
        }

        default:
        {
        	adl_atSendResponse ( ADL_AT_UNS,"\r\n Server_WIP_CEV_default");
        	break;
        }
    }

}

void appli_tcp_entry_point()
{
socket0S = wip_TCPServerCreate ( (u16)ServerPort, &evh_tcp_server, NULL );
}

in addition. Often in case of a read and write of data there is an application reset.
I use versions:
Open AT Framework: 2.51.0.201206190958
Firmware 7.51.0.201205311751
Q2687RD

additional information to a question.
did experiment. after creation the channel requested parameters by means of function wip_readOpts.
function returned an error-998. it is possible to look at a working example about the server?
or prompt where I am wrong in a code
char buffer [512];
int i, nread, nwrite;
u32 SndBufsize;
u32 RcvBufsize;
u32 SndLowat;
u32 RcvLowat;
u32 Snd_Timeaut;
bool Nodelay;
u8 Tos;
u8 TTL;
u32 RexmtMax;
u32 Rexmt_Maxcnt;
socket0S = wip_TCPServerCreate((u16) ServerPort, &evh_tcp_server, NULL);
nread = wip_readOpts( socket0S, buffer, sizeof( buffer),
WIP_COPT_SND_BUFSIZE, & SndBufsize,
WIP_COPT_RCV_BUFSIZE, & RcvBufsize,
WIP_COPT_SND_LOWAT, & SndLowat,
WIP_COPT_RCV_LOWAT, & RcvLowat,
WIP_COPT_SND_LOWAT, & Snd_Timeaut,
WIP_COPT_NODELAY, & Nodelay,
WIP_COPT_TOS, & Tos,
WIP_COPT_TTL, & TTL,
WIP_COPT_REXMT_MAX, & RexmtMax,
WIP_COPT_REXMT_MAXCNT, & Rexmt_Maxcnt,
WIP_COPT_END);

I am sorry for my English, but the help is very necessary. really anybody faced similar problems? If that that isn’t clear in the problem description, is ready to explain.