Toolbox.NETMF.NET.WiFlySocket

This class uses the SimpleSocket interface to access the WiFly IP stack.

Toolbox.NETMF.NET.WiFlySocket(Hostname, Port, NetworkInterface)
  • Hostname The remote hostname
  • Port The remote TCP port
  • NetworkInterface A reference to a WiFlyGSX module

Methods

See the interface SimpleSocket for a full list of methods

Sample code in C#

// Declares the WiFly module, configures the IP address and joins a wireless network
WiFlyGSX WifiModule = new WiFlyGSX();
WifiModule.EnableDHCP();
WifiModule.JoinNetwork("Netduino");

// Showing some interesting output
Debug.Print("Local IP: " + WifiModule.LocalIP);
Debug.Print("MAC address: " + WifiModule.MacAddress);

// Creates a socket
SimpleSocket Socket = new WiFlySocket("www.netmftoolbox.com", 80, WifiModule);

// Connects to the socket
Socket.Connect();

// Does a plain HTTP request
Socket.Send("GET /helloworld/ HTTP/1.1\r\n");
Socket.Send("Host: " + Socket.Hostname + "\r\n");
Socket.Send("Connection: Close\r\n");
Socket.Send("\r\n");

// Prints all received data to the debug window, until the connection is terminated
while (Socket.IsConnected)
{
    Debug.Print(Socket.Receive());
}

// Closes down the socket
Socket.Close();

Sample code in VB

' Declares the WiFly module, configures the IP address and joins a wireless network
Dim WifiModule As WiFlyGSX = New WiFlyGSX()
WifiModule.EnableDHCP()
WifiModule.JoinNetwork("Netduino")

' Showing some interesting output
Debug.Print("Local IP: " + WifiModule.LocalIP)
Debug.Print("MAC address: " + WifiModule.MacAddress)

' Creates a socket
Dim Socket As SimpleSocket = New WiFlySocket("www.netmftoolbox.com", 80, WifiModule)

' Connects to the socket
Socket.Connect()

' Does a plain HTTP request
Socket.Send("GET /helloworld/ HTTP/1.1" + Constants.vbCrLf)
Socket.Send("Host: " + Socket.Hostname + Constants.vbCrLf)
Socket.Send("Connection: Close" + Constants.vbCrLf)
Socket.Send(Constants.vbCrLf)

' Prints all received data to the debug window, until the connection is terminated
Do While Socket.IsConnected
    Debug.Print(Socket.Receive())
Loop

' Closes down the socket
Socket.Close()

Last edited May 31, 2012 at 1:30 PM by Garrcomm, version 4