PC Review


Reply
Thread Tools Rate Thread

Datagram Socket Crashes when too much data to send!

 
 
=?Utf-8?B?TGlvbmVsIFJleWVybw==?=
Guest
Posts: n/a
 
      10th Jun 2005
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...=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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxleCBZYWtobmluIFtNVlBd?=
Guest
Posts: n/a
 
      10th Jun 2005
Do you really require the buffer that big?

Have you tried use a smaller buffer (1 KB) max and send the data in chunks?

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org


"Lionel Reyero" wrote:

> 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...=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
>

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      10th Jun 2005
Remember that calls to SendTo() don't have their data concatenated into some
great big packet which is then sent to the destination (as they might on a
TCP socket, where there's no packetization defined; the data just looks like
a stream). Alex's suggestion is worth trying. Change *nothing* about the
send buffer size (leave it at the default, as this was undoubtedly the
best-tested configuration by MS). Make sure that none of your calls to
SendTo() are specifying more than 1000 or so bytes (there are packet size
restrictions on UDP). Still crashes? Device details?

Paul T.

"Alex Yakhnin [MVP]" <(E-Mail Removed)> wrote in message
news:34F2DC8C-BDAE-4CEE-87CF-(E-Mail Removed)...
> Do you really require the buffer that big?
>
> Have you tried use a smaller buffer (1 KB) max and send the data in
> chunks?
>
> --
> Alex Yakhnin, .NET CF MVP
> www.intelliprog.com | www.opennetcf.org
>
>
> "Lionel Reyero" wrote:
>
>> 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...=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
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to send ascii data over the tcp socket in VB.NET. Valli Microsoft Dot NET 3 31st May 2007 06:27 PM
Socket.Send crashes phone cyberco Microsoft Dot NET Compact Framework 6 31st Jan 2007 03:24 PM
Will The OS send more then one message in a datagram, if it has the room, for efficiency. DaTurk Microsoft C# .NET 2 14th Jun 2006 11:21 PM
Datagram Socket Speed Problem =?Utf-8?B?TGlvbmVsIFJleWVybw==?= Microsoft Dot NET Compact Framework 3 3rd Jun 2005 01:21 AM
WINS error 4204 datagram protocol (UDP) socket Ron Morgan Microsoft Windows 2000 Networking 1 21st Nov 2003 01:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 AM.