Hardware Reference
In-Depth Information
The dns parameter is a string and is the domain name to connect to. It is auto-
matically converted to an IP address via a DNS query.
connect() returns a boolean: true if the connection is made, otherwise it
returns false .
It is possible to check the status of a connection calling client.connected() .
result = client.connected();
This function does not take any parameters and returns true if the client is
still connected and false if it is no longer connected. Note that if data is still
waiting to be read, then this function returns true , even if the connection has
been severed.
To disconnect from a server, use stop() .
client.stop();
This function takes no parameters and does not return any data. It simply
severs the network connection.
Sending and Receiving Data
Sending and receiving data is done through a stream; data can either be written
in binary format or in text format. To send text data, use print() and println() .
client.print(data);
client.print(data, BASE);
client.println();
client.println(data);
client.println(data, BASE);
The difference between print() and println() is that println() adds a
new line character to the end of the string. The data parameter is the string or
data to print, and the optional BASE argument is the numerical system to use.
The data parameter is either a String or an array of char .
To write binary data, use write() .
client.write(val);
client.write(buf, len);
The val parameter is a byte to send over the TCP/IP link. The buf parameter
is an array of bytes, and the len parameter specii es the number of bytes to send.
To read from the network socket, use read() .
data = client.read();
This function does not take any parameters and returns the next byte in the
stream, or -1 if no data is available. To check if data is waiting to be read, use
available() .
 
Search WWH ::




Custom Search