help on SetDeadline implementation for a connection

606 views
Skip to first unread message

pala.d...@gmail.com

unread,
Apr 13, 2013, 6:18:29 AM4/13/13
to golan...@googlegroups.com
Hello, I've just released a simple implementation of rfc 1006 (i.e. ISO/IEC 8072/8073 transport class 0 on top of a TCP/IP):

https://github.com/danielePala/tosi
http://godoc.org/github.com/danielePala/tosi

I used the interfaces defined in the 'net' package (http://golang.org/pkg/net), and in particular the Conn interface (http://golang.org/pkg/net/#Conn): this requires the implementation of methods called 'SetDeadLine', 'SetReadDeadLine' and 'SetWriteDeadLine', to set a timeout for I/O operations. Right now I just wrapped the underlying TCP method, however, a tosi Read or Write call may imply more than one TCP Read or Write, so that the deadline may be surpassed.

I don't know how to implement these methods in a more consistent way, so that the deadline is always respected. Anyone can help me?

Thanks a lot,
Daniele Pala

Mikio Hara

unread,
Apr 13, 2013, 7:02:45 AM4/13/13
to pala.d...@gmail.com, golang-nuts
On Sat, Apr 13, 2013 at 7:18 PM, <pala.d...@gmail.com> wrote:

> Hello, I've just released a simple implementation of rfc 1006 (i.e. ISO/IEC
> 8072/8073 transport class 0 on top of a TCP/IP):

Congrats, a few comments.

- You can say just RFC 1006 in the package description because
godoc.org can parse it
- Also s/net.Dial/tosi.Dial/ in the package description
- s/Tosi/TOSI/, like not Tcp but TCP in Go stdlib

> I don't know how to implement these methods in a more consistent way, so
> that the deadline is always respected. Anyone can help me?

I guess you should implement own Deadline stuff if tosi.Read, Write require
internal message exchange over TCP at each call.

pala.d...@gmail.com

unread,
Apr 13, 2013, 8:09:32 AM4/13/13
to golan...@googlegroups.com, pala.d...@gmail.com
Thanks a lot for your comments!! I've updated the documentation and changed 'Tosi' to 'TOSI' in the API.
For the deadline question, the problem is that, generally, I don't know how many TCP transactions a tosi.Read will produce, for example, if I receive an invalid PDU I have to respond back with an ER (error) PDU, which requires a TCP Write...so there is no defined TCP deadline that I can set...

Daniele Pala

Mikio Hara

unread,
Apr 13, 2013, 11:55:28 AM4/13/13
to pala.d...@gmail.com, golang-nuts
On Sat, Apr 13, 2013 at 9:09 PM, <pala.d...@gmail.com> wrote:

> For the deadline question, the problem is that, generally, I don't know how
> many TCP transactions a tosi.Read will produce, for example, if I receive an
> invalid PDU I have to respond back with an ER (error) PDU, which requires a
> TCP Write...so there is no defined TCP deadline that I can set...

On solution would be that using every 10-30ms (an appropriate deadline)
TCP read, write subsequent to main PDU read.

P.S.
s/net.Listen/tosi.Listen/ in the description.
Selector might be better than Tsel at TOSIAddr.

pala.d...@gmail.com

unread,
Apr 14, 2013, 3:40:23 AM4/14/13
to golan...@googlegroups.com, pala.d...@gmail.com
mmm, or maybe I can put up something like the example shown in time.After (http://golang.org/pkg/time/#After)...need to think about that.
Many thanks for the corrections, for the 'Tsel' name, for now I'll leave it as it is, I prefer short names :-)

Daniele
Reply all
Reply to author
Forward
0 new messages