zeromq / clrzmq4

ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
GNU Lesser General Public License v3.0
241 stars 112 forks source link

ZFrame constructors should ensure the postcondition Position == 0 #110

Closed sigiesec closed 5 years ago

sigiesec commented 7 years ago

Currently, the ZFrame constructors accepting a string will position the ZFrame stream at the end. This makes the use confusing. It might even be considered a bug.

sigiesec commented 7 years ago

E.g. the following code will not work as expected (see https://stackoverflow.com/questions/42768088/c-sharp-zframe-data-extraction):

ZMessage msg = new ZMessage();   
msg.Add(new ZFrame("AABBCCDD"));            
var str = msg.PopString();

str will be empty afterwards.

Alternatives to changing the behaviour of the ZFrame constructors, this might be fixed by

  1. Rewinding a ZFrame on ZMessage.Add
  2. Rewinding a ZFrame on ZMessage.Pop

However, I think changing the behaviour of the ZFrame constructors is preferrable.

sigiesec commented 7 years ago

See also #111, which would eliminate this issue along.

metadings commented 5 years ago

Closing this issue. It's too old