MySensors Library & Examples  2.3.2-36-g2e00bf6
Public Member Functions | Friends | List of all members
EthernetClient Class Reference

Detailed Description

EthernetClient class

Definition at line 43 of file EthernetClient.h.

#include <EthernetClient.h>

+ Inheritance diagram for EthernetClient:
+ Collaboration diagram for EthernetClient:

Public Member Functions

 EthernetClient ()
 EthernetClient constructor.
 
 EthernetClient (int sock)
 EthernetClient constructor. More...
 
virtual int connect (const char *host, uint16_t port)
 Initiate a connection with host:port. More...
 
virtual int connect (IPAddress ip, uint16_t port)
 Initiate a connection with ip:port. More...
 
virtual size_t write (uint8_t b)
 Write a byte. More...
 
virtual size_t write (const uint8_t *buf, size_t size)
 Write at most 'size' bytes. More...
 
size_t write (const char *str)
 Write a null-terminated string. More...
 
size_t write (const char *buffer, size_t size)
 Write at most 'size' characters. More...
 
virtual int available ()
 Returns the number of bytes available for reading. More...
 
virtual int read ()
 Read a byte. More...
 
virtual int read (uint8_t *buf, size_t bytes)
 Read a number of bytes and store in a buffer. More...
 
virtual int peek ()
 Returns the next byte of the read queue without removing it from the queue. More...
 
virtual void flush ()
 Waits until all outgoing bytes in buffer have been sent.
 
virtual void stop ()
 Close the connection gracefully. More...
 
uint8_t status ()
 Connection status. More...
 
virtual uint8_t connected ()
 Whether or not the client is connected. More...
 
void close ()
 Close the connection.
 
void bind (IPAddress ip)
 Bind the conection to the specified local ip.
 
int getSocketNumber ()
 Get the internal socket file descriptor. More...
 
virtual operator bool ()
 Overloaded cast operators. More...
 
virtual bool operator== (const bool value)
 Overloaded cast operators. More...
 
virtual bool operator!= (const bool value)
 Overloaded cast operators. More...
 
virtual bool operator== (const EthernetClient &rhs)
 Overloaded cast operators. More...
 
virtual bool operator!= (const EthernetClient &rhs)
 Overloaded cast operators. More...
 

Friends

class EthernetServer
 

Constructor & Destructor Documentation

◆ EthernetClient()

EthernetClient::EthernetClient ( int  sock)
explicit

EthernetClient constructor.

Parameters
sockNetwork socket.

Member Function Documentation

◆ available()

virtual int EthernetClient::available ( )
virtual

Returns the number of bytes available for reading.

Returns
number of bytes available.

◆ connect() [1/2]

virtual int EthernetClient::connect ( const char *  host,
uint16_t  port 
)
virtual

Initiate a connection with host:port.

Parameters
hostname to resolve or a stringified dotted IP address.
portto connect to.
Returns
1 if SUCCESS or -1 if FAILURE.

◆ connect() [2/2]

virtual int EthernetClient::connect ( IPAddress  ip,
uint16_t  port 
)
virtual

Initiate a connection with ip:port.

Parameters
ipto connect to.
portto connect to.
Returns
1 if SUCCESS or -1 if FAILURE.

◆ connected()

virtual uint8_t EthernetClient::connected ( )
virtual

Whether or not the client is connected.

Note that a client is considered connected if the connection has been closed but there is still unread data.

Returns
1 if the client is connected, 0 if not.

◆ getSocketNumber()

int EthernetClient::getSocketNumber ( )

Get the internal socket file descriptor.

Returns
an integer, that is the socket number.

◆ operator bool()

virtual EthernetClient::operator bool ( )
virtual

Overloaded cast operators.

Allow EthernetClient objects to be used where a bool is expected.

◆ operator!=() [1/2]

virtual bool EthernetClient::operator!= ( const bool  value)
inlinevirtual

Overloaded cast operators.

Definition at line 186 of file EthernetClient.h.

◆ operator!=() [2/2]

virtual bool EthernetClient::operator!= ( const EthernetClient rhs)
inlinevirtual

Overloaded cast operators.

Definition at line 199 of file EthernetClient.h.

◆ operator==() [1/2]

virtual bool EthernetClient::operator== ( const bool  value)
inlinevirtual

Overloaded cast operators.

Definition at line 178 of file EthernetClient.h.

◆ operator==() [2/2]

virtual bool EthernetClient::operator== ( const EthernetClient rhs)
virtual

Overloaded cast operators.

◆ peek()

virtual int EthernetClient::peek ( )
virtual

Returns the next byte of the read queue without removing it from the queue.

Returns
-1 if no data, else the first byte of incoming data available.

◆ read() [1/2]

virtual int EthernetClient::read ( )
virtual

Read a byte.

Returns
-1 if no data, else the first byte available.

◆ read() [2/2]

virtual int EthernetClient::read ( uint8_t *  buf,
size_t  bytes 
)
virtual

Read a number of bytes and store in a buffer.

Parameters
bufbuffer to write to.
bytesnumber of bytes to read.
Returns
-1 if no data or number of read bytes.

◆ status()

uint8_t EthernetClient::status ( )

Connection status.

Returns
state according to W5100 library codes.

◆ stop()

virtual void EthernetClient::stop ( )
virtual

Close the connection gracefully.

Send a FIN and wait 1s for a response. If no response close it forcefully.

◆ write() [1/4]

size_t EthernetClient::write ( const char *  buffer,
size_t  size 
)

Write at most 'size' characters.

Parameters
bufferto read from.
sizeof the buffer.
Returns
0 if FAILURE or the number of characters sent.

◆ write() [2/4]

size_t EthernetClient::write ( const char *  str)

Write a null-terminated string.

Parameters
strString to write.
Returns
0 if FAILURE or number of characters sent.

◆ write() [3/4]

virtual size_t EthernetClient::write ( const uint8_t *  buf,
size_t  size 
)
virtual

Write at most 'size' bytes.

Parameters
bufBuffer to read from.
sizeof the buffer.
Returns
0 if FAILURE or the number of bytes sent.

◆ write() [4/4]

virtual size_t EthernetClient::write ( uint8_t  b)
virtual

Write a byte.

Parameters
bbyte to write.
Returns
0 if FAILURE or 1 if SUCCESS.

The documentation for this class was generated from the following file: