Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket.Send throw exception with 'The descriptor is not a socket' #590

Closed
ctacke opened this issue Apr 9, 2024 · 6 comments
Closed

Socket.Send throw exception with 'The descriptor is not a socket' #590

ctacke opened this issue Apr 9, 2024 · 6 comments

Comments

@ctacke
Copy link
Contributor

ctacke commented Apr 9, 2024

Meadow F7 Project Lab
OS v 1.10.0.2

MeadowSocketSend Test application attached

I have a pair of very simple applications, a client and sender that use a Socket for communication.
The "Client" app runs on a PC, accepts and listens for a sender to attach.
The "Sender" connects, and sends a simple text message.

This works fine on a desktop machine.
On the Meadow, the call to Send throw an exception with the message "The descriptor is not a socket"

@jbeenes
Copy link

jbeenes commented Apr 9, 2024

We have been struggling with WebSockets on Meadow too, using System.Net.WebSockets. Did you test with this aswell?

In our search to get our test working I came across this link, where the part under Remarks made me think this might never work on something other then Windows. Do you agree?

We made it work eventually using a library called SocketSharp.

Ps. I have not tested it on Linux btw.

@djaus2
Copy link

djaus2 commented Apr 10, 2024

I am currently experiencing a related problem "The descriptor is not a socket".
My code is similar to @ctacke code as above.

Situation:

  • TCP Service running on an Arduino device
  • Client that connects to it implemented as a .NET Class library
  • .NET 6 or 8 and .NET Standard 2.1
  • Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    • Also tried as TCPClient with same result.
  • All works OK from desktop as 2 apps
    • .NET Console app with .NET Class
    • Blazor App with .NET Class
  • In Meadow context ProjectLabs device
    • Using .NET Standard version of Library
    • Can connect
    • Get "The descriptor is not a socket" error when sending to service
    • Of note is that the Client.Available property returns that error.
  • Can run OK as Meadow.Windows app on desktop using either .NET or .NET Standard class library.

I did use while (Client.Available == 0) ; which would obviously fail if .Available is errant. Replaced it with a several second wait and app hung.

Have drilled into this a bit on Slack: https://wildernesslabspublic.slack.com/archives/CB9BW8HQE/p1712460726231349

@djaus2
Copy link

djaus2 commented Apr 11, 2024

Have posted Softata with MeadowLabs app version on GitHub: djaus2/Soft-ata
MeadowLab app generates this error.

@duduita
Copy link

duduita commented Apr 22, 2024

The core of this issue lies in the Socket.Available property, which relies on a native function that is currently unsupported by our operating system version. The OS rebase, expected in the coming months, should definitively resolve this problem.

As a temporary solution, the Socket.Available property will return 1 when there are bytes ready to be read and 0 when there aren't. While this workaround may not provide exact data availability, it serves as a reliable indicator of whether the socket contains readable data, and also eliminates the The descriptor is not a socket exception occurrence.

@djaus2
Copy link

djaus2 commented Apr 23, 2024 via email

@ctacke
Copy link
Contributor Author

ctacke commented May 1, 2024

Fixed in 1.11

@ctacke ctacke closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants