Main Site Documentation

Socket problem - SocketOperationOnNonSocket (ErrorCode 10038)


#1

In some situations (not clear), EMX network access fails. The network adapter then becomes totally inaccessible from outside and from inside the EMX.

I have managed to recreate behaviour that might look the same: The network then gets a lot of Socket ErrorCodes 10038 for every Connect I do

Is there any way of resetting socket to get it work again when such things happen?

Environment:
A GPRS router for internet access, with DHCP to vendor host
EMX firmware version 4.1.6.0, static IP to GPRS router typical 192.168.2.101. Router LAN 192.168.2.1. DNS to external servers and to GPRS router

The GPRS router switches IP addresses from time to time

Thanks


#2

You are using PPP, correct?


#3

Yes, PPP.

The case is, I am not familiar with this GPRS router.

The case is also, the location of the routers are in the countryside. The signals should be good, but the router do connect/reconnect several times during 24h, i.e it switches its DHCP IP ~5 times (+)

Thanks


#4

[quote]but the router do connect/reconnect several times during 24h, i.e it switches its DHCP IP ~5 times (+)
[/quote]
There is some misunderstanding here. Do you mean that Dhcp is used or static IP at EMX’s side?

[quote]The network adapter then becomes totally inaccessible from outside and from inside the EMX.
[/quote]
Could you please explain a bit more? Are you sure that the connection was not dropped?

When do you ge this exception?

This particular socket error means: Invalid socket descriptor. An invalid socket descriptor was passed to an API function. The socket descriptor returned by calls to socket or accept needs to be passed to bind/connect/send, etc.

The problem description is not clear yet. I suggest that you try the application using Ethernet first. Also I suggest that you use static IP first. If it worked fine then try to isolate the issue while using PPP by making a simple and short code example that recreates the issue.


#5

I took a while, but here is more

More specifically, the GPRS is an external unit, not on the board, so the EMX is actually using Ethernet.

The external GPRS is switching its external DHCP IP from time to time, but the LAN is continued as is

I have tried to recreate failure to get a 10038 socket exception:

The following happens:

  • I connected EMX with DHCP to LAN - network working
  • I added static IP on EMX - network still working
  • I switch IP settings on router, changes the router LAN IP - then the EMX loses its network and gets timouts
  • I then switch back IP settings on router, the network on EMX still down
  • I then set DHPC IP on EMX, and now it starts failing, throwing 10038 exceptions. The socket never gets on the track again. Every connection made to the socket fails with 10038

I think the EMX should have restored without locking/loosing the socket

This behaviour is also reported to the NETMF in http://netmf.codeplex.com/workitem/1396

This happens more often on the EMX with the external GPRS router then if the network is on cable, then there is hardly any problem (it still happens though)


#6

It seems to me that if it’s reported in netmf then it’s an IP stack issue.

It also seems to me that the artificial way you reproduced this isn’t likely to happen in real life? The LAN address should never change without someone manually doing this, like you have. Any other network device that “owns” a network address space like this should shield connected devices from the internet connection IP address changing.

The fault seems to arise when you do this:

at that point, a normal network device should then be able to see the rest of the IP network. In your case, your app doesn’t. Perhaps you can build some robustness into that area of your code?