Downgrade to 4.1 - Gadgeteer toolbox

I’ve downgraded from 4.2 to 4.1 because Socket.Send randomly hangs (and by hangs I mean everything, all threads and also the debugger that when I try to stop hangs the visual studio also).

But now, all the controls have disappear; the 4.1 doesn’t have designer support?

How exactly did you “downgrade”? If you mean you uninstalled 4.2 then I think you still need that installed. You just need to point your projects to the 4.1 libraries. You should still have controls in your toolbox.

I’ve installed GHI NETMF v4.1 SDK and after that used the 4.1 Fez Spider Updater; if I create a new 4.1 gadgeteer app I have no control in toolbox; the same happens if I change the Target Framework of an existing 4.2 app to 4.1

@ allex4project -

I think I found a workaround for the send issue on 4.2. set the socket tcp option nodelay to true.

@ Mike - I went back to 4.2 and test it - unfortunately it doesn’t work.

I’m so disappointed; I can’t understand how this bug ended in the rtm; the basic communication fails:

            
int size = 50000;
byte[] arr = new byte[size];

            for (int i = 0; i < 100; i++)
            {
                Debug.Print("Sending... (#" + i.ToString() + ")  Size:" + arr.Length.ToString());
                socket.Send(arr);
                //Thread.Sleep(200);
                Debug.Print("Sent.");
            }

Fails at the third send.

do you really need to send 50000 bytes in a single send? GHI should look into why 50000 fails, but what do you really need to send?

and if you really want to work on 4.1, that’s ok, but you need to install the 4.2 SDK and 4.2 Gadgeteer set again and just target 4.1 as your desired framework. Make sure you “update” the firmware to 4.1 in unison though.

Maybe there is problem with your server. Catch SocketException, and inspect the socket error code Windows Sockets Error Codes (Winsock2.h) - Win32 apps | Microsoft Learn

Hi,
I think you have the same problem as Tal-McMahon. I think the reason is, that the socket buffer gets full. http://www.tinyclr.com/forum/topic?id=9878&page=3#msg98411
Roland

@ tvinko - There is no exception; just hangs.

I had a same problem. The only difference was, that I had to open and close socket after each sending. The code works fine, but when the server becomes unavailable, the client just hangs. Then I add socketexeption catch, and reboot the system. I know that this is not elegant solution, but works for me.


private void SendData2ServerBugWrapper(string sValue)
        {
            while (IPAddress.GetDefaultLocalAddress().ToString() == "0.0.0.0")
                Thread.Sleep(500);

            try
            {
                SendDataByServerIP(ApplicationSettings.ServerIP, ApplicationSettings.ServerPort, sValue);
            }
            catch (SocketException eex)
            {
                if (eex.ErrorCode == 10055)
                {
                    if (ApplicationSettings.AlternateServerIP != "")
                    {
                        try
                        {
                            SendDataByServerIP(ApplicationSettings.AlternateServerIP, ApplicationSettings.AlternateServerPort, sValue);
                        }
                        catch (SocketException ex)
                        {
                            if (eex.ErrorCode == 10055)
                                DoReboot = true;
                        }
                    }
                    else
                        DoReboot = true;
                }
            }
        }

 private void SendDataByServerIP(string sServerIP, int iServerPort, string sValue)
        {
            using (Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {
                try
                {
                    IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(sServerIP), iServerPort);
                    clientSocket.Connect(serverEndPoint);

                    byte[] msg = Encoding.UTF8.GetBytes(sValue + "<EOF>");
                    clientSocket.Send(msg);
                    clientSocket.Close();
                    m_IsSendDataSuccedded = true;
                }
                catch (Exception ex)
                {
                    Debug.Print("Exception");
                }
                finally
                {

                }
            }
        }



@ Mike - Yes, I need to send at least 50k, it is a picture. Actually I try to send every time the BitmapStreamed event of the camera it is raised. I’ve tried with the web server; it is more than 3 times slower than with the socket - but with the socket is unreliable.

@ tvinko - Since I kinda try to do some streaming closing and reopening the socket won’t do for me.

@ RoSchmi - The buffer getting full is what I also suspect; I tried to change the size using the SetSocketOption with SocketOptionName.SendBuffer, but it throws exception.

Try partial sending : Socket Send and Receive [C#] (code is for .NET, but can be easily translated)