Problem regarding wip_TCPServerCreate() function


i have a little ambiguity regarding a function that is wip_TCPServerCreate().This function creates a channel encapsulating a TCP Server Socket.
The prototype of the function is:
wip_TCPServerCreate(u16 port,wip_eventhandler_f spawnedHandler,void *ctx);

PORT:The port number on which TCP server socket listens.
SpawnedHandler:The callback handler that receives events related to the TCP Clients.
ctx:User data passed to the event handlers of spawned sockets.
this function returns a created channel or NULL on error but when i pass an invalid port e.g 99999 which is out of the range i.e >65535,it should return NULL rather than returning a created channel.also when i pass a valid n unused port and run my server application and then allows client application to establish a connection to server on a specfic IP and port,client is unable to establish the connection and returns with an error i.e
“error -986 on socket.closing… TCP connection”.where error number -986 indicates that timeout occurs .so there is a doubt that server application is not binding the port correctly with socket as server IP is valid and is being pinged basically i am unable to answer two questions that why this function is taking an invalid port and successfully returning a created channel and why error of timeout is arising at client side when a valid and unused port is being passed at the server side and Server IP is also successfully pinged.

i will appreciate any assistance extended to me in this regard…anticipating an urgent response



99999 is not just out of range of 65535 but out of range of u16 type, so it is probably truncated when passed to function. In reality your function accepts value (99999 % 65536).
Your module could be pinged but not visible by clients because of your provider NAT rules. Check if your module is really pinged from a PC side (and not pinged when switched off), and after that try to set port number to 80 which is for HTTP and should pass every firewall.


This is standard behaviour of the ‘C’ programming language - nothing specifically to do with wip_TCPServerCreate() or Open-AT…


@blackyblack…thanks alottt for replying .my module is getting pinged from pc side and when it is off it is not pinged and if it is getting pinged publicily then it means that it is also visible to clients.may be these ports over which i am trying to establish tcp/ip connectivity are blocked over my GPRS network as IP assigned to server is public and static so there is no chance of NAT problem to be arised…:slight_smile:…need your further assistance in this regard.


Note that some GPRS networks block pings…


So did you try using 80 port for connection?


@awneil…thx for replying…not is not blocked .server is getting pinged successfully…
@blackyblack…yeah i tried port 80 but it also didnt work…:frowning:


You have mentioned error -986 on client side. Do you use wavecom module as a TCP client to an another wavecom module as a TCP server? Or your client is on a PC side. Please provide more information on your hardware configuration…


yup i am using wavecom module as a TCP client and another wavecom module as a tcp server.but in order to trace out the root cause i also tried pc as a client by using telnet utility but still i m unable to find out the core problem…thanks alot for your keen interest.need yours further assistance in this regard.


So how did PC client worked? Have it connected to server or not? Proceed with your experiments step by step. First set up TCP server on a PC and connect to it with telnet. Then start TCP server on wavecom module, checking all return and error codes. Check that your WIP plugin is actually started, GPRS is opened, bearer is opened and started… Set TCP port to 80 to avoid problems with firewalls. And now start connection from PC side and check how it is beeing processed on the module.


Hi sunnyday,
I have the same problem and I don’t even have a clue why is it happening. If you change the port the client will connect. But the problem may happen again. The strangest thing is when I try to connect with at commands the client connects to the server. But when I try to connect to the same server on the same port with API application, the client won’t connect and always returns Error -986. Very strannge.