Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Bug in system.net.sockets


  • Please log in to reply
3 replies to this topic

#1 rhamer

rhamer

    Member

  • Members
  • PipPip
  • 29 posts
  • LocationMelbourne Australia

Posted 24 January 2012 - 10:28 PM

I have just encountered some strange behaviour with the socket.send() method in V4.2

using the following code, I get an exception thrown on every ninth byte.

    Public Function SendData(Data As Byte) As Boolean

        Dim ret As Boolean
        Dim DataByteArray() = {Data}

        Try
            clientSocket.Send(DataByteArray)
            ret = True
        Catch ex As Exception
            ret = False
        End Try

        Return ret

    End Function

This happens reliably every time.

The other odd thing is when I look at the data using wireshark, the data in the packets is always as follows.

1 data byte
7 data bytes
(exception thrown byte never sent)
1 data byte
7 data bytes
(exception thrown byte never sent)

this pattern continues until there is no more data to send.

If I catch the false return from the above method and just call the method again with the same byte, it works, so it is not the contents of the byte that is the problem (it is also different with every ninth byte not being the same data anyway)

Recalling the same method after an exception fixes the problem in as much as the byte is eventually sent, but it slows down the execution dramatically as you can imagine, and is not an acceptable workaround.

Can anybody think of something I might be doing wrong?

Regards

Rohan

#2 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 25 January 2012 - 01:00 AM

Just to clarify, you are sending a single byte with each call of "clientSocket.Send" ? -Valkyrie-MT

#3 rhamer

rhamer

    Member

  • Members
  • PipPip
  • 29 posts
  • LocationMelbourne Australia

Posted 25 January 2012 - 01:56 AM

Just to clarify, you are sending a single byte with each call of "clientSocket.Send" ?

-Valkyrie-MT


Yes that is correct.

Regards

Rohan

#4 rhamer

rhamer

    Member

  • Members
  • PipPip
  • 29 posts
  • LocationMelbourne Australia

Posted 25 January 2012 - 04:05 AM

Further to my example above, I can confirm the following code example does not have the problem.

    Public Function SendDataArray(Data() As Byte) As Boolean

        Dim ret As Boolean

        Try
            clientSocket.Send(Data)
            ret = True
        Catch ex As Exception
            ret = False
        End Try

        Return ret

    End Function

The difference here is I'm passing a byte array into the method (instead of just a byte) which should make no difference at all, except the array contains more than 1 byte.

I can repeatedly call this method with no exceptions being generated.

Regards

Rohan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.