473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Avoiding buffer overflow / receiving udp dgrams

Hello!

I'm not sure if this is the right place to ask my question...
According to the docs, it is possible to receive udp datagrams asynchronous
using the Socket-class and its .BeginRecive(From) method. My problem is that
I can't figure out how big the receive-buffer should be.

When my programs fires the receive-callback function, I call the
EndReceive(From) method to copy the received datagrams to the buffer that
I've supplied earlier in the BeginReceive(From) method. It's a
Byte()-variable with a fixed size (32kb).

-->
m_Gateway.BeginReceiveFrom(m_Buffer, 0, m_Buffer.Length, SocketFlags.None,
m_remoteEP, AddressOf UDPCallback, Nothing)

<--

m_Buffer is initialized with a fixed size of 32kb.

Whenever my application receives a large amount of data (>32kb) my
receive-callback terminates with an exception "there was more data to
receive" (translated from german)... Of course, this error only occures when
my receive-buffer is too small:

-->

lRead = m_Gateway.EndReceiveFrom(iarg, m_remoteEP)

<--
Is there any possibility to "see" the size of the received data -before-
calling .EndReceive(From)? I've tried the .Available property but its value
is either "0" or much too small.

It can't be that I need to supply a hardcoded-sized Byte()-buffer, can it?

Nov 20 '05 #1
0 1037

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Ioannis Vranos | last post by:
If we want our programs to be protected against buffer overflows, must we check the size of the various containers explicitly? E.g. #include <iostream> #include <string> int main()
4
by: Ramiro Barbosa, Jr. | last post by:
All, In regards to the call below, I was wondering why is it that the 'szMessage' receiving buffer results in an empty one, but by printing 'ret' it indicates the number of bytes I am indeed...
2
by: jay | last post by:
I am attempting to impersonate an account in ASPNET. I am using aspnet_setreg to store the username and passwords. I have given the ASPNET account permisision to read the registry values. However,...
9
by: Notebooker | last post by:
Hello, I'm an intermediate noob reading-in data from ascii-file using an ifstream object. I have specified a c-style string buffer with size of type size_t and I am specifying to use this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.