UDP none blocking recvfrom(... RTCS_MSG_PEEK ...) causing RTCSERR_UDP_PORT_ZERO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UDP none blocking recvfrom(... RTCS_MSG_PEEK ...) causing RTCSERR_UDP_PORT_ZERO

Jump to solution
3,563 Views
CarlFST60L
Senior Contributor II

Hi,

 

RTCS_geterror(sock); is returning

 

#define RTCSERR_UDP_PORT_ZERO    (RTCS_ERROR_BASE|0x665)    /* can't send to port 0  */

 

after I do something like this (just to illustrate easily the problem):

 

sendto();

_time_delay(10);

recvfrom(... RTCS_MSG_PEEK  ...); //no data to receive as the turn around time is 100mS

//Quickly try to resend

sendto(); //This will ALWAYS return the above error

 

so I tried this

 

sendto();

_time_delay(1);

recvfrom(... RTCS_MSG_PEEK  ...); //no data to receive as the turn around time is 100mS

shutdown(sock...);

sock = socket(PF_INET, SOCK_DGRAM, 0);

error = bind(sock, &local_sin, sizeof(local_sin));

sendto(); //This will ALWAYS return the above error

 

 

The point is, I need to be able to have a UDP timeout and retry, so i need to use recvfrom() as a non blocking to make my timeout, but cannot work out what to do to shutdown() and socket_bind()  to get it to come back so that I can send again...

 

 Normally,if message peek returns no error and none zero, I do a normal recvfrom(); to get the datagram. all this works fine, ist only a problem when the timeout happens

 

Message Edited by CarlFST60L on 2010-02-03 06:29 AM
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
929 Views
CarlFST60L
Senior Contributor II
the problem was solved, you have to reset remote_sin after callign shutdown();

View solution in original post

0 Kudos
Reply
4 Replies
929 Views
CarlFST60L
Senior Contributor II

CW = Current 7.1.2 with all updates, MQX = Current 3.4, target 52259evb using MRAM debug for testing.

 

 

in user_config.h, I only have UDP, ICMP and GATEWAY's enabled, all the other RTCS stuff is off.

0 Kudos
Reply
929 Views
CarlFST60L
Senior Contributor II

We have now tested this with MQX3.5 with no usable result.

 

We are desperately in need of a working UDP timeout example or idea on how to get it going as RTCS and its documentation is clearly lacking in this fundamental area.

we just need to send a packet, if it doesn't get the response, close the connection, reopen and resend. Using RTCS_MSG_PEEK causes the next sendto(); to return an error. there must be more to shutting down that just
shutdown();
socket();
bind();
after timeout using RTCS_MSG_PEEK error.

I hope I am just making a simple mistake, but I am unable to progress based on the examples / documentation.

0 Kudos
Reply
930 Views
CarlFST60L
Senior Contributor II
the problem was solved, you have to reset remote_sin after callign shutdown();
0 Kudos
Reply
929 Views
prodsp
Contributor I
Please give the environment used ( CW version, MQX version, Target ) !
0 Kudos
Reply