WebServer.StartLocalServer fails!


    public partial class Program
    {
        string ipAddress = "192.168.0.93";
        string nsk = "hidden";

        WebEvent index;
 
        void ProgramStarted()
        {
            wifi_RS21.Interface.Open();
            GHI.Premium.Net.NetworkInterfaceExtension.AssignNetworkingStackTo(wifi_RS21.Interface);
            wifi_RS21.Interface.NetworkInterface.EnableStaticIP(ipAddress, "255.255.255.0", "192.168.0.1");
            WiFiNetworkInfo[] scanResults = wifi_RS21.Interface.Scan();
            WiFiNetworkInfo info = new WiFiNetworkInfo(scanResults[0]);
            wifi_RS21.Interface.Join(info, nsk);


            index = WebServer.SetupWebEvent("index.html");
            index.WebEventReceived += new WebEvent.ReceivedWebEventHandler(index_WebEventReceived);


            ////Here Error
            WebServer.StartLocalServer(ipAddress, 80);



            Debug.Print("Program Started");
        }

        void index_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            
        }
    }


[quote]Using mainboard GHI Electronics FEZSpider version 1.0
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::bind [IP: 0000] ####
#### System.Net.Sockets.Socket::Bind [IP: 0016] ####
#### Gadgeteer.Networking.WebServerManager+Server::StartLocal [IP: 002d] ####
#### Gadgeteer.Networking.WebServerManager::StartServer [IP: 0012] ####
#### Gadgeteer.Networking.WebServer::StartLocalServer [IP: 0014] ####
#### TestWiFiWebServer.Program::ProgramStarted [IP: 007d] ####
#### TestWiFiWebServer.Program::Main [IP: 0015] ####
#### SocketException ErrorCode = 10022
#### SocketException ErrorCode = 10022
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10022
An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll[/quote]

What am I doing wrong?

http://www.ghielectronics.com/community/forum/topic?id=3559&page=2#msg33817

10022 seems to be invalid argument.

Ps: it’d help if you told us what line the exception occurred on

@ Brett - StartLocalServer() from the trace.

@ Brett - I’ve put “////Here Error” in code, or as Mike says, from the trace.

The thing is that everything else works; it responds to ping!

Figure it out myself; it works this way:


            wifi_RS21.Interface.WirelessConnectivityChanged += new WiFiRS9110.WirelessConnectivityChangedEventHandler(Interface_WirelessConnectivityChanged);




        void Interface_WirelessConnectivityChanged(object sender, WiFiRS9110.WirelessConnectivityEventArgs e)
        {
            if (e.IsConnected)
            {
                WebServer.StartLocalServer(wifi_RS21.Interface.NetworkInterface.IPAddress, 80);
            }
        }