Datagram Socket Crashes when too much data to send!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

I have already started a topic on a problem related to Datagram Socket Speed
Problem, it is at this address :
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.framework.compactframework&tid=2e1306f5-64fb-4d8c-b6e9-d4bd0268780d&cat=en-us-msdn-mobile-wince&lang=en&cr=US&sloc=en-us&m=1&p=1

I am still having problems with that one...

In my application, I am sending data "as fast as possible" into a datagram
socket, which is blocking, and which has a 400 kbyte sendbuffer. The code is
similar to this:

while (keepAlive)
{
byte[] data = dataSource.getData();

int sentData = socket.SendTo(data , 0, dataSize, SocketFlags.None,
remoteEndPoint);

//If I add this line, it is working fine
//Thread.Sleep(50);
}

If the Thread.Sleep() line is commented, the application will crash almost
instantly... I get no exception, no error... the connection with Visual
Studio .NET 2003 is lost, the application is shut down... and the Ipaq
network features are not working any more.. only a soft reset can bring it
back working.

I don't understand why the socket.SendTo() function does not block the
application untill the data is sent... It seems it only copies the data into
an internal buffer, and stupidly crashes when this buffer is full.

If I uncomment the line Thread.Sleep(), then the application is working.
This line is slowing down the application so that the data rate is low enough
for the socket to send it.

Paul G. Tobey tried to help me already. He suggested to check the value
returned by socket.SendTo()... unfortunately this value is always positive
and equals to the size of the byte[] the application is sending. So
everything seems to behave like normal, but it crashes completely....

What can I do to ensure the application is sending the data as fast as
possible ?
And also to be sure it will not crash ?

Thanks a lot for your patience to read this! :-)

Lionel Reyero

.



Relevant Pages

  • Re: How do I define the Source port value when creating a socket
    ... I have the crash log from the event viewer listed below. ... I am using the WSAcalls, are they the MFC ... Or are there other socket calls in MFC. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Threaded app using sockets closes
    ... You can use DEBUGMSGor OutputDebugStringto send messages indicating the thread's progress to the Output window in eVC. ... When you closesocket(), unless you've configured the socket for immediate close, it goes through a process to try to close the socket in a clean way, so that might take some time and I'm unsure whether closesocketwaits for that before returning or not. ... Now I'm trying to reproduce my error, but a new one occured. ... It's in totally new place where normally the app doesn't crash but I didn't notice it's not doing what it's expected to do. ...
    (microsoft.public.windowsce.embedded.vc)
  • TCP sockets -- accept() returns -1
    ... While debugging a mysterious crash in our application, the strace output ... The segmentation fault is because the program assumes a socket being ... then there is a connection pending to be ...
    (comp.os.linux.development.apps)
  • Re: How do I define the Source port value when creating a socket
    ... > Thanks so much for your advice. ... > But if I may ask, I tried to just do the Bindon the same socket I ... When you have a crash you need to record the location of it, ... another advice would be to stay away from MFC sockets wrappers and use plain ...
    (microsoft.public.win32.programmer.networks)
  • RE: Datagram Socket Crashes when too much data to send!
    ... Have you tried use a smaller buffer max and send the data in chunks? ... > I have already started a topic on a problem related to Datagram Socket Speed ... > If the Thread.Sleepline is commented, the application will crash almost ... and stupidly crashes when this buffer is full. ...
    (microsoft.public.dotnet.framework.compactframework)