TCP socket example

@ PiWi - That’s a nice piece of source you have there. I have investigated a bit and found this source from the XSOCKETS project. It’s MIT licensed and has an approach for the client I really like. It is lightweight and handles commands as well and offers a small event layer. Direct events (what I found out from network devices) are not available on Gadgeteer platforms. Here the link to the source:

https://github.com/XSockets/XSockets.Clients/blob/master/src/XSockets.Clients/XSockets.ClientMF43/XSocketClient.cs

1 Like

@ AWSOMEDEVSIGNER - If you are refering to the …WebServer… piece of code, that’s gadgeteer build-in only it had a bug (in the Responder.cs), in some procedure they had an index misfit was just a matter of a letter I thought is was change an i into j or vice versa and then it worked. Maybe they fixed it in the meanwhile and included in 2.43.1000 so I didn’t look further … I’ll see if it is fixed and working, if it’s fixed, then I’m gonna setup a raptor project with the barebones and mail it 2 ye …

1 Like

@ PiWi - Sounds great! Thanks :slight_smile: I will try to develop a barebone-skeleton for outgoing and incoming message notifications. First, because I need it for a current project and second because I think that others will love it as well. Simple but versatile.

Managed a few seconds ago to compile the NETMF CodePlex distribution without any patching :smiley:

@ AWSOMEDEVSIGNER - Too bad … not fixed yet …

[quote]Create TS.

Loading start at 202d8818, end 20307cac

Assembly: mscorlib (4.3.1.0) Assembly: Microsoft.SPOT.Native (4.3.1.0) Assembly: Microsoft.SPOT.Security.PKCS11 (4.3
.1.0) Assembly: System.Security (4.3.1.0) Assembly: Microsoft.SPOT.Hardware (4.3.1.0)
Assembly: Microsoft.SPOT.Graphics (4.3.1.0) Assembly: Microsoft.SPOT.TinyCore (4.3.1.0)
Assembly: Microsoft.SPOT.IO (4.3.1.0) Assembly: System.IO (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0) Assembly: Microsoft.SPOT.Touch (4.3.1.0)
Assembly: Microsoft.SPOT.Ink (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)
Loading Deployment Assemblies.

Attaching deployed file.

Assembly: Gadgeteer (2.43.1.0) Attaching deployed file.

Assembly: GHI.Hardware (4.3.6.0) Attaching deployed file.

Assembly: Gadgeteer.WebServer (2.43.1.0) Attaching deployed file.

Assembly: System (4.3.1.0) Attaching deployed file.

Assembly: GHIElectronics.Gadgeteer.FEZRaptor (4.3.6.0) Attaching deployed file.

Assembly: GHI.Usb (4.3.6.0) Attaching deployed file.

Assembly: GHI.Pins (4.3.6.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Net (4.3.1.0) Attaching deployed file.

Assembly: WebServer (1.0.0.0) Attaching deployed file.

Assembly: GHI.Networking (4.3.6.0) Resolving.

GC: 1msec 333624 bytes used, 66772140 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 66772140 bytes

Type 17 (ASSEMBLY ): 36876 bytes

Type 1E (BINARY_BLOB_HEAD ): 296652 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction…

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Native.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.Security.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Graphics.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.TinyCore.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.IO.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.IO.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Touch.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Ink.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Net.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.3\le\Gadgeteer.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.3\le\Gadgeteer.WebServer.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Usb.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZRaptor\NETMF 4.3\le\GHIElectronics.Gadgeteer.FEZRaptor.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Pins.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Networking.dll’
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Users\Peter\Documents\Visual Studio 2015\Projects\Raptor\PureNetMf\WebServer\bin\Debug\le\WebServer.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
06/01/2011 05:51:39 Board: GHI Electronics FEZ Raptor 1.0
06/01/2011 05:51:39 OEM : Copyright (C) GHI Electronics, LLC
06/01/2011 05:51:39 SDK : 4.3.6.0

06/01/2011 05:51:39 Preparing the network…
06/01/2011 05:51:42 Joining … AK16
06/01/2011 05:51:48 Network joined.

06/01/2011 05:51:48 Waiting for network address …
06/01/2011 05:51:49 Waiting for network address …
06/01/2011 05:51:49 Waiting for network address …
06/01/2011 05:51:49 Waiting for network address …
06/01/2011 05:51:49 Waiting for network address …
06/01/2011 05:51:49 Network availability = True
06/01/2011 05:51:50 Waiting for network address …
06/01/2011 05:51:50 Waiting for network address …
06/01/2011 05:51:50 Waiting for network address …
06/01/2011 05:51:50 Waiting for network address …
06/01/2011 05:51:50 Network address change
06/01/2011 05:51:51 New address for the Network Interface
06/01/2011 05:51:51 Is DHCP enabled: True
06/01/2011 05:51:51 Is DynamicDnsEnabled enabled: True
06/01/2011 05:51:51 NetworkInterfaceType 71
06/01/2011 05:51:51 Network settings:
06/01/2011 05:51:51 IP Address: 192.168.39.19
06/01/2011 05:51:51 Subnet Mask: 255.255.255.0
06/01/2011 05:51:51 Default Gateway: 192.168.39.123
06/01/2011 05:51:51 MAC Address: 00-23-A7-1E-45-B9
06/01/2011 05:51:51 Number of DNS servers: 1
06/01/2011 05:51:51 DNS Server 0:192.168.39.123
06/01/2011 05:51:51 ------------------------------------------------------

06/01/2011 05:51:51 Grabbing the time from … de.pool.ntp.org

01/04/2015 02:36:12 Date and time updated thru NTP

01/04/2015 02:36:12… the blue LED should be blinking now …
Web server started at http://192.168.39.19:80/
01/04/2015 02:36:27 webserver started !
#### Exception System.IndexOutOfRangeException - 0xa9000000 (5) ####
#### Message:
#### Gadgeteer.Networking.Responder::FindHeaderSection [IP: 0034] ####
#### Gadgeteer.Networking.Responder::Parse [IP: 004b] ####
#### Gadgeteer.Networking.WebServerManager+Server::ProcessRequest [IP: 0090] ####
A first chance exception of type ‘System.IndexOutOfRangeException’ occurred in Gadgeteer.WebServer.dll
The thread ‘’ (0x5) has exited with code 0 (0x0).[/quote]

But, that’s a known bug. Need to re-generate a Gadgeteer.WebServer.dll I thought …

Edit: Look here for the report → https://gadgeteer.codeplex.com/workitem/1861

1 Like

@ PiWi - We could fix that on our own. But that’s really hilarious. How old is this bug?

@ AWSOMEDEVSIGNER - Yep, I’m already working on it, seposedly reported on April 16th, this year …

1 Like

@ AWSOMEDEVSIGNER - IT’S ALIVE, IT’S ALIVE …

And that all in VS2015 (had to compile the webserver source in VS2012 though) and from an iPad …

[quote]01/04/2015 03:36:04… the blue LED should be blinking now …
Web server started at http://192.168.39.19:80/
01/04/2015 03:36:11 webserver started !
DefaultEvent received @ 01/04/2015 03:36:28
URL:
Remote request from: 192.168.39.130:49754
Headers: GET / HTTP/1.1
Host: 192.168.39.19
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
User-Agent: Mozilla/5.0 (iPad; CPU OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4
Accept-Language: nl-nl
Cache-Control: max-age=0
Connection: keep-alive

DefaultEvent done @ 01/04/2015 03:36:28
The thread ‘’ (0x5) has exited with code 0 (0x0).[/quote]

Source is in the mail …

[em]Note: I had to fully qualify the Gadgeteer.Networking.WebServer etc on all references although I had the namespace in my usings … whatever, it is a beta, I shouldn’t be complaning too much.
[/em]

Used only a Raptor with RS21 (chip antenna) in socket 1

1 Like

@ PiWi - Awesome! Can’t wait to test that in a few hours (need some sleep).

Hi, what is the issue with that array? I believe I have the same problem, but no idea on how / where to fix it.

Thanks.


 #### Exception System.IndexOutOfRangeException - 0xa9000000 (6) ####
    #### Message: 
    #### Gadgeteer.Networking.Responder::FindHeaderSection [IP: 0034] ####
    #### Gadgeteer.Networking.Responder::Parse [IP: 004b] ####
    #### Gadgeteer.Networking.WebServerManager+Server::ProcessRequest [IP: 0090] ####
A first chance exception of type 'System.IndexOutOfRangeException' occurred in Gadgeteer.WebServer.dll

@ Elezium - https://www.ghielectronics.com/community/forum/topic?id=16330

Edit: Or look at this thread → https://www.ghielectronics.com/community/forum/topic?id=16375&page=1#msg162452

Thanks. I got it working. Not the fastest, but it’s working. :wink:

Appreciated.