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

Socket.Receive max out on 256 bytes?


  • Please log in to reply
5 replies to this topic

#1 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 26 September 2011 - 12:27 PM

I'm porting a FTP client class I have lying around (it's actually from Microsoft in 2003) to the .NETMF and VB.net. However, after the port the code halts as it can't receive more than 256 bytes from the FTP server, regardless the size of the buffer.

Just for fun, I copied the class to a regular Console application. It works without problems.

Here's the code.
Do While (True)
            Array.Clear(m_aBuffer, 0, BLOCK_SIZE)
            m_iBytes = m_objClientSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
            Debug.Print("m_iBytes: " & m_iBytes)
            m_sMes += Encoding.UTF8.GetChars(m_aBuffer, 0, m_iBytes)
            Debug.Print("m_sMes in loop: " & m_sMes)
            If (m_iBytes < m_aBuffer.Length) Then
                Debug.Print("m_iBytes is less than the buffer")
                Exit Do
            End If
        Loop


The BLOCK_SIZE is set to 512. m_objClientSocket.Receive stops after reading 256 bytes. I tried to change the size to 128 just to test it. The loop continues until .Receive has read a TOTAL of 256 bytes.


I am lost. Any pointers? :)

#2 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 26 September 2011 - 06:33 PM

I forgot to add the Class. See the ReadLine() function:

Attached Files



#3 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 27 September 2011 - 08:14 AM

Anybody? Is it a bug with either the VB implementation or Sockets?

#4 erich

erich

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationFrance

Posted 27 September 2011 - 11:43 AM

Does it run in the Emulator? I am also having socket.Connect issues in C#(different config). It hangs before the stage you are at, but works OK in the emulator.

#5 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 27 September 2011 - 11:53 AM

I haven't tested with the emulator yet, but I will.

I sometimes have issues when Creating the socket:
m_objClientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)

and... resolving the DNS seldom works. I have to use the direct IP.
Dim ip As System.Net.IPAddress = Dns.GetHostEntry(m_sRemoteHost).AddressList(0)
Dim ep As New IPEndPoint(ip, m_iRemotePort)


There seems to be some issues with Sockets in the 4.2 RC... :(

EDIT: You're right. In the emulator it works without hickups.

#6 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 27 September 2011 - 01:22 PM

Hmmmm! I believe the network connection for the Netduino is deemed "unstable" at best... I'll open a new thread on that.




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.