Fabian Koch:
I am in the position where I would need SOCKET_SO_SNDTIMEO to have Send() at least return after a while when e.g. I unplugged the cable.
Now, I understand that sockopt is unimplemented in LwIP.
Not sockopt in general, but SO_SNDTIMEO is not implemented, that's right.
Could I achieve a similar behavior using sys_timeout()?
Hmm, don't call sys_timeout in the application thread, it won't work (and with CVS head you risk threading problems!).
Creating a timeout before calling netconn_write()/_send() and when the timer runs out, have a callback that leaves op_completed for that conn, probably with api_callback so it is executed in stack-context?
When send was sucessful, I'd call sys_untimeout() and be done with it.

Is that feasable in any way or too much fiddling around with internal states of the stack?
In general (using tcpip_(un)timeout instead of sys_(un)timeout), this might work, but *yes*, it's not wise to trust on implmentation details: your code will most definitively not work with 1.4.0 when it's working allright with 1.3.x.

Still, if you need this functionality, you not only have to signal 'op_completed' but also reset 'write_msg', 'write_offset' and 'state' (to NETCONN_NONE) - all the things do_writemore() does when it's finished.

A more sophisticated way to implement this (which might even have the potential to be included in CVS?) would be to have a timstamp when write was started and let poll_tcp() or do_writemore() check whether the operation timed out (using sys_now() to get the timestamp and compare it). If you do that, it would be nice to share the work as a patch entry on savannah.

Simon
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to