For server two functions:
- openServerTCP() to set listener
- pollingAccept() to receive link request
For client only one:
- openSockTCP()
And closeSock() for both
As server:
MWiFi.openServerTCP(int port)
port : port number (>1000)
local server socket (int)(for polling using)
MWiFi.pollingAccept(int serversocket)
serversocket: socket returned by opneServer()
a socket linked with client (int)
0xFF (255) otherwise
As client:
MWiFi.openSockTCP(char *remoteIP, int port)
remoteIP: pointer to a char string (null terminated) containing remote address
Format: "n.n.n.n"
port: port number (>1000)
a socket for communication (int)
0xFF (255) otherwise (can't open link)
For Server and client
MWiFi.closeSock(int socket)
socket to close
none
#include <MWiFi.h> //library include
MWiFi WIFI; //instance of MWiFi
int ssocket;
int csocket=0xFF;
void setup() {
WIFI.begin(); // startup shield
:
WIFI.ConnSetOpen("DLink-casa");
int fc=WIFI.Connect();
:
ssocket=WIFI.openServerTCP(5000);
}
void loop()
{
if (csocket==255) //don't poll if link already established
{
int s=WIFI.pollingAccept(ssocket);
if (s<255) csocket=s;
}
}