TinyPPP
PPP networking over any Arduino Stream
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PPPClient Class Reference

TCP client over PPP: used like WiFiClient or EthernetClient. More...

#include <PPPSockets.h>

Inheritance diagram for PPPClient:

Public Member Functions

 PPPClient ()=default
 Client on the default stack (the first TinyPPP instance)
 
 PPPClient (IPStack &stack)
 Client on the indicated stack.
 
 PPPClient (IPStack *stack, int sock)
 Client for an existing socket (used by PPPServer)
 
int available () override
 Number of received bytes that can be read.
 
int connect (const char *host, uint16_t port) override
 Resolves the host via DNS and connects: returns 1 on success.
 
int connect (IPAddress ip, uint16_t port) override
 Connects to the address and port: returns 1 on success.
 
uint8_t connected () override
 true while connected or while received data is available
 
void flush () override
 Waits until all written data was acknowledged by the peer.
 
uint16_t localPort ()
 Our port.
 
 operator bool () override
 true if the client refers to an open socket
 
bool operator!= (const PPPClient &other) const
 true if they refer to different connections
 
bool operator== (const PPPClient &other) const
 true if both refer to the same connection
 
int peek () override
 Next byte without removing it (-1 if none)
 
int read () override
 Reads one byte (-1 if none available)
 
int read (uint8_t *buf, size_t size) override
 Reads up to size bytes: returns the number read or -1.
 
IPAddress remoteIP ()
 Address of the peer.
 
uint16_t remotePort ()
 Port of the peer.
 
void setConnectionTimeout (uint32_t ms)
 Timeout in ms for connect, write and flush.
 
void stop () override
 Closes the connection.
 
size_t write (const uint8_t *buf, size_t size) override
 Sends data (waits while the send buffer is full)
 
size_t write (uint8_t b) override
 Sends one byte.
 

Protected Member Functions

IPStack * stack () const
 
bool valid () const
 

Protected Attributes

uint8_t _gen = 0
 
int _sock = -1
 
IPStack * _stack = nullptr
 
uint32_t _timeout = 5000
 

Detailed Description

TCP client over PPP: used like WiFiClient or EthernetClient.

Copies refer to the same connection; it is closed by stop() only.

Constructor & Destructor Documentation

◆ PPPClient() [1/3]

PPPClient ( )
default

Client on the default stack (the first TinyPPP instance)

◆ PPPClient() [2/3]

PPPClient ( IPStack &  stack)
inlineexplicit

Client on the indicated stack.

◆ PPPClient() [3/3]

PPPClient ( IPStack *  stack,
int  sock 
)
inline

Client for an existing socket (used by PPPServer)

Member Function Documentation

◆ available()

int available ( )
inlineoverride

Number of received bytes that can be read.

◆ connect() [1/2]

int connect ( const char *  host,
uint16_t  port 
)
inlineoverride

Resolves the host via DNS and connects: returns 1 on success.

◆ connect() [2/2]

int connect ( IPAddress  ip,
uint16_t  port 
)
inlineoverride

Connects to the address and port: returns 1 on success.

◆ connected()

uint8_t connected ( )
inlineoverride

true while connected or while received data is available

◆ flush()

void flush ( )
inlineoverride

Waits until all written data was acknowledged by the peer.

◆ localPort()

uint16_t localPort ( )
inline

Our port.

◆ operator bool()

operator bool ( )
inlineoverride

true if the client refers to an open socket

◆ operator!=()

bool operator!= ( const PPPClient &  other) const
inline

true if they refer to different connections

◆ operator==()

bool operator== ( const PPPClient &  other) const
inline

true if both refer to the same connection

◆ peek()

int peek ( )
inlineoverride

Next byte without removing it (-1 if none)

◆ read() [1/2]

int read ( )
inlineoverride

Reads one byte (-1 if none available)

◆ read() [2/2]

int read ( uint8_t *  buf,
size_t  size 
)
inlineoverride

Reads up to size bytes: returns the number read or -1.

◆ remoteIP()

IPAddress remoteIP ( )
inline

Address of the peer.

◆ remotePort()

uint16_t remotePort ( )
inline

Port of the peer.

◆ setConnectionTimeout()

void setConnectionTimeout ( uint32_t  ms)
inline

Timeout in ms for connect, write and flush.

◆ stack()

IPStack * stack ( ) const
inlineprotected

◆ stop()

void stop ( )
inlineoverride

Closes the connection.

◆ valid()

bool valid ( ) const
inlineprotected

◆ write() [1/2]

size_t write ( const uint8_t *  buf,
size_t  size 
)
inlineoverride

Sends data (waits while the send buffer is full)

◆ write() [2/2]

size_t write ( uint8_t  b)
inlineoverride

Sends one byte.

Member Data Documentation

◆ _gen

uint8_t _gen = 0
protected

◆ _sock

int _sock = -1
protected

◆ _stack

IPStack* _stack = nullptr
protected

◆ _timeout

uint32_t _timeout = 5000
protected

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