Writes buffer on output stream of socket.
Buffer can be provided with its length or can be just a null terminated char string.
Also a version adding line feed is provided
MWiFi.writeData(int socket,byte *buffer,int bufferlen)
MWiFi.writeData(int socket, char *buffer)
MWiFi.writeDataLn(int socket, char *buffer)
socket : link socket
buffer : a byte array or a char array null terminated
bufferlen : length of buffer
number of bytes really sent (int)
#include <MWiFi.h> //library include
MWiFi WIFI; //instance of MWiFi
int ssocket; //server socket
int csocket=0xFF; //communication socket
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;
}
if (csocket<255) //only when link exists
{
WIFI.writeDataLn(csocket,"Just a test");
}
}