kity hong wrote:
> Hi, Jan
> 
> We are using RTNET 0.7.0.
>  And we have a problem: the master is sending request while the slave
> reboot. So there is a chance before the slave finished initializing
> socket, the RTNET stack already received the packet , which make the
> slave delay to receive the correct packet, one buffer delay.
> 
> Is there a method to flush socket (that is clean up the stack receving
> packet) in RTNET implementation? is it possible to make the path from
> the packet receiver to RTNET interrupted atificially until RTNET is
> finished initialization?
> 
> here is the initializing socket we used.
> 
> void ut_sock_init (void)
> {
>     unsigned long dest_ip = rt_inet_aton(dest_ip_s);
>     int ret;
>     struct rtnet_callback   callback  = {cb_recv, NULL};
> 
>     /* create rt-socket */
>     sock = socket_rt(AF_INET, SOCK_DGRAM, 0);
>     if (sock < 0) {
>         DebugCheckDcSub(DEBUG_RT_SOCK, DEBUG_ERROR)
>             PRINT_ERR ("ERR: socket_rt() = %d!<ut_sock_init>\n", sock);
>         return;
>     }
> 
>     /* extend the socket pool */
>     ret = ioctl_rt(sock, RTNET_RTIOC_EXTPOOL, &add_rtskbs);
>     if (ret != (int)add_rtskbs) {
>         DebugCheckDcSub(DEBUG_RT_SOCK, DEBUG_ERROR)
>             PRINT_ERR ("ERR: ioctl_rt(RT_IOC_SO_EXTPOOL) = %d
> <ut_sock_init>\n", ret);
>         close_rt(sock);
>         return;
>     }
> 
>     /* bind the rt-socket to a port */
>     memset(&local_addr, 0, sizeof(struct sockaddr_in));
>     local_addr.sin_family = AF_INET;
>     local_addr.sin_port = htons(PORT);
>     local_addr.sin_addr.s_addr = INADDR_ANY;
>     ret = bind_rt(sock, (struct sockaddr *)&local_addr, sizeof(struct
> sockaddr_in));
>     if (ret < 0) {
>         DebugCheckDcSub(DEBUG_RT_SOCK, DEBUG_ERROR)
>             PRINT_ERR ("ERR: bind_rt() = %d!<ut_sock_init>\n", ret);
>         close_rt(sock);
>         return;
>     }
> 
>     /* set destination address */
>     memset(&dest_addr, 0, sizeof(struct sockaddr_in));
>     dest_addr.sin_family = AF_INET;
>     dest_addr.sin_port = htons(PORT);
>     dest_addr.sin_addr.s_addr = dest_ip;
>       
>       /* set up callback handler */
>     ioctl_rt(sock, RTNET_RTIOC_CALLBACK, &callback);

I'm not yet sure I fully got your problem, but maybe it is just that
your register the reception callback after binding to the respective
port. If you flip both, you should be able to avoid missing any packets
that arrive in the middle of them.

> }
> 
> I am appreciated for possible reply. thank you!
> 
> Kity

HTH,
Jan

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------

_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to