Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DGramSocket Exception Tokens Missing
#1
Getting this in the SNMP driver. Tokens are not being filled in...

Unhandled Exception (MEng.System.Runtime.DGramSocket #16) - The max buffer size (%(1)) is smaller than the bytes requested (%(2))

BTW, I get this when I do a

c4Count := m_Sock.ReadFrom(ipSrc, 0, m_bufResp, Card4.kMaxValue);

Is that the expected behaviour? Shouldn't kMaxValue be LARGER than any possible buffer size?
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#2
What are you using for the constructor for the buffer? The docs only list 1 constructor that requires a starting and maximum size, but you can use a default constructor with just MemBuf m_bufResp;. Maybe this is using some type of default maximum size that is less than kCard4.MaxValue.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#3
Looking at the 2nd paragraph for the ReadFrom() method tells the story I believe...So it will only expand the buffer to its maximum size that was set when it was initialized. The only way the buffer would get to Card4.kMaxValue would be if that was what the buffer was initialized at.

Quote:If the passed memory buffer's maximum size is not sufficient to hold the packet, a SocketErrors.DGramBufToSmall exception will be thrown. Be careful though, because this method will allocate the buffer up to the ToRead size, so don't set the buffer max to some ridiculous value and set ToRead to that value, because it will allocate the buffer up to that size. Datagram packets are limited in size anyway, so set it to some reasonable size, such as 32K and that should hold any legal datagram packet.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#4
Ok, that explains it. I wasn't thinking about the buffer itself, that max is probably much smaller. I was just trying to flush the socket buffer since reloading the driver wasn't doing it. There is no method on the DGram socket to close it. I found another way by checking if data is available first.

Thanks.

The tokens still need to be fixed in the exception though...
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#5
I'll take care of the error message tokens. And also the outgoing datagram sender was comparing the bytes to send to the max buffer size instead of the current buffer allocation which was wrong also. The incoming should compare against the max and the outgoing should compare against the current. So I fixed that also. It's the little things in life...
Dean Roddey
Explorans limites defectum
Reply
#6
What I find interesting with things like this is it really shows the power and complexity of the product. Even though the product itself is fairly mature basic things like the buffer comparison still crop up because a vast majority of the code base is under-utilized. Just goes to show if you have enough monkeys pounding on keyboards it will eventually flush out most things.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#7
I'm always amazed at how long bugs can exist without being ever noticed. Some of them it seems would be impossible to go unnoticed by they'll be there for many years before something happens that brings them to light. Iit's heading towards 800K lines of code, so I guess that's not to be unexpected. But with so much code, you'd think that basically almost all the methods of the underlying fundamental stuff (like sockets) would be used fairly commonly.

But there's a lot of stuff down there, and of course people try not to write code with errors and to do the right thing, so sometimes it's only when the docs are insufficient or misunderstood or under-read that people will do something wrong that brings out something like this.
Dean Roddey
Explorans limites defectum
Reply
#8
Do you have an official release number for the underlying CIDLib Framework? Last open source release was 1.1.0 and that has been 9 years.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#9
I think no one is using DGramSockets. SNMP is UDP based, and UDP is pretty rare these days.

But if anything is going to pull out some bugs it's this friggin SNMP driver. I don't know how many lines of code it has, but it's one complex beast. I was going to add some simple enhancements today and I am already many hours in...
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#10
I just keep the CQC and CIDLib code base versions the same, for simplicity's sake. So it's at whatever release the CQC stuff is.

The Omni driver has been UDP based for a long time, but of course I know now it all works so I never did anything that would have raised the issue above.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unhandled system exception in the GUI Thread gReatAutomation 9 2,270 03-23-2020, 01:03 PM
Last Post: Dean Roddey
Photo Unhandled GUI Exception simplextech 3 1,282 01-05-2020, 03:27 PM
Last Post: zra
  Unhandled system exception in GUI Thread Shaky 75 20,844 06-21-2019, 08:10 PM
Last Post: kblagron
  Missing how to tell CQC to read a Lutron keypad button pressed ghurty 7 2,844 01-08-2019, 09:55 PM
Last Post: Dean Roddey
  System.Runtime.FileSystem documentation missing? rbroders 1 1,564 11-25-2018, 07:44 PM
Last Post: Dean Roddey
  ISY scenes and relays missing carealtor 1 1,322 11-12-2018, 10:22 PM
Last Post: Dean Roddey
  Drivers missing zra 29 16,198 07-05-2017, 07:38 PM
Last Post: Dean Roddey
  Lumagen Radiance fields missing dlmorgan999 14 8,699 02-18-2017, 11:04 AM
Last Post: dlmorgan999
  Is CQCIdGen missing from v5? ghurty 6 3,604 11-14-2016, 03:32 PM
Last Post: Dean Roddey
  CQC 4.7.22 - Bound Method Missing in DGramSocket wuench 1 1,821 10-31-2015, 08:21 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)