what is the difference between class server and Ethernet server and so does class client and Ethernet client.And i wonder when should we use the Enternet udp class?
And i don't quite understand the following sentence:
Client client = server.available();
if (client == true)
The return of the server.available is boolen right? How it can give the value to the client.
Thanks for reading and helping.
what is the difference between class server and Ethernet server and so does class client and Ethernet client.
In what context? I suspect that you are confusing the instance name and the class name.
And i wonder when should we use the Enternet udp class?
When you want to send or receive UDP packets.
And i don't quite understand the following sentence:
Client client = server.available();
if (client == true)
I don't either. Why one would compare an instance to true or false escapes me. Now, if(client) simply tests whether there was a client instance available for processing.
The return of the server.available is boolen right?
No. You can look at the source code and see that.
berlin,
what is the difference between class server and Ethernet server and so does class client and Ethernet client.
Please note on the changes page (Arduino Reference - Arduino Reference ): "Renamed Ethernet Client, Server, and UDP classes to EthernetClient, EthernetServer, and EthernetUDP to allow for simultaneous use of other networking libraries." The Arduino web pages remain confusing, retaining both Server() and EthernetServer(). I suspect that's there for backward compatibility, but just use EthernetServer() or EthernetClient().
The return of the server.available is boolen right? How it can give the value to the client.
The call to EthernetServer.available() returns the client (EthernetClient() object) that has called in to talk to the server. Also, they've added a boolean operator to these classes to enable a boolean test in for/while loops, etc. as in:
EthernetClient::operator bool() {
return _sock != MAX_SOCK_NUM;
}
Hope this helps.
Thanks Pauls,I just read it from the arduino.cc/reference,it comes out two client(Ethernclient) and it confuses me.
About udp,i mean it which situantion should we use it?
Thanks,Mister-Transisitor. When you get some trouble,you should turn to the code first,right?I wonder where i can find the source code.
I wonder where i can find the source code.
Where did you install the Arduino IDE software? That location should contain a libraries folder that contains the core libraries.
About udp,i mean it which situantion should we use it?
UDP is typically used to broadcast messages when the sender doesn't care whether any particular receiver gets the message. Like a radio station broadcasts, whether your radio is on or not, whether it is tuned to that station or not, and whether you are actually listening or not.
If the sender is sending temperature data, the order pf packets is not really critical, as the temperature is not likely to change that much from one packet to the next, and, even if the packets arrive out of order, the next one should correct the problem. If order is important, you have two choices. Either don't use UDP or include order information in the packet. Of course, doing that is an attempt to convert UDP to TCP, so you might as well use TCP instead.
I got it,thanks a lot!