COSA
An Object-Oriented Platform for Arduino Programming
|
#include <Socket.hh>
Public Types | |
enum | Protocol { TCP = SOCK_STREAM, UDP = SOCK_DGRAM, IPRAW = SOCK_RAW, MACRAW = SOCK_RDM, PPPoE = SOCK_SEQPACKET } |
Public Member Functions | |
Socket () | |
void | src (INET::addr_t &addr) const |
Protocol | proto () const |
uint16_t | port () const |
virtual int | write (const void *buf, size_t size) |
virtual int | write_P (const void *buf, size_t size) |
virtual int | getchar () |
virtual int | read (void *buf, size_t size) |
virtual int | open (Protocol proto, uint16_t port, uint8_t flag)=0 |
virtual int | close ()=0 |
virtual int | listen ()=0 |
virtual int | accept ()=0 |
virtual int | connect (uint8_t addr[4], uint16_t port)=0 |
virtual int | connect (const char *hostname, uint16_t port)=0 |
virtual int | is_connected ()=0 |
virtual int | disconnect ()=0 |
virtual int | datagram (uint8_t addr[4], uint16_t port)=0 |
int | send (const void *buf, size_t len) |
int | send_P (const void *buf, size_t len) |
virtual int | recv (void *buf, size_t len)=0 |
int | send (const void *buf, size_t len, uint8_t dest[4], uint16_t port) |
int | send_P (const void *buf, size_t len, uint8_t dest[4], uint16_t port) |
virtual int | recv (void *buf, size_t len, uint8_t src[4], uint16_t &port)=0 |
void | non_blocking () |
void | blocking () |
bool | is_blocking () const |
void | eol (Mode mode) |
Mode | eol () const |
virtual int | available () |
virtual int | room () |
virtual int | putchar (char c) |
virtual int | puts (const char *s) |
virtual int | puts (str_P s) |
virtual int | write (const iovec_t *vec) |
virtual int | peekchar () |
virtual int | peekchar (char c) |
virtual char * | gets (char *s, size_t count) |
virtual int | read (iovec_t *vec) |
virtual int | flush () |
virtual void | empty () |
Static Public Attributes | |
static const uint16_t | DYNAMIC_PORT = 49152 |
Protected Member Functions | |
virtual int | write (const void *buf, size_t size, bool progmem) |
virtual int | send (const void *buf, size_t len, bool progmem)=0 |
virtual int | send (const void *buf, size_t len, uint8_t dest[4], uint16_t port, bool progmem)=0 |
Protected Attributes | |
INET::addr_t | m_src |
uint8_t | m_proto |
uint16_t | m_port |
bool | m_blocking |
Mode | m_eol |
enum Socket::Protocol |
|
inline |
|
pure virtual |
Check for incoming requests from clients. Return zero if the socket has accepted a request and a connection is established.
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
virtualinherited |
Number of bytes available (possible to read).
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, Soft::UART, UART, IOBuffer< SIZE >, and CC3000::Driver.
Definition at line 24 of file IOStream_Device.cpp.
|
inlineinherited |
Set blocking mode.
Definition at line 85 of file IOStream.hh.
|
pure virtual |
Close the socket.
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
pure virtual |
Connect the socket to the given address and port; client mode.
[in] | addr | destination address. |
[in] | port | destination port. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
pure virtual |
Connect the socket to the given hostname and port; client mode. Returns zero if connection established otherwise negative error code.
[in] | hostname | string. |
[in] | port | destination port. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
pure virtual |
Start the construction of a datagram to the given address and port.
[in] | addr | destination address. |
[in] | port | destination port. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
pure virtual |
Disconnect socket from server.
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
virtualinherited |
Empty internal device buffers.
Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.
Definition at line 175 of file IOStream_Device.cpp.
|
inlineinherited |
Set end of line mode.
[in] | mode | for end of line. |
Definition at line 103 of file IOStream.hh.
|
inlineinherited |
|
virtualinherited |
Flush internal device buffers. Wait for device to become idle.
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.
Definition at line 169 of file IOStream_Device.cpp.
|
inlinevirtual |
|
virtualinherited |
Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.
[in] | s | string buffer to read into. |
[in] | count | max number of bytes to read. |
Definition at line 118 of file IOStream_Device.cpp.
|
inlineinherited |
|
pure virtual |
Returns positive integer if a connection is established, zero is not yet established, otherwise a negative error code.
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
pure virtual |
Mark socket for incoming requests; server mode.
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
inlineinherited |
Set non-blocking mode.
Definition at line 77 of file IOStream.hh.
|
pure virtual |
Initiate socket to the given protocol and possible port.
[in] | proto | protocol. |
[in] | port | source port. |
[in] | flag | socket options. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
virtualinherited |
Peek at the next character from device.
Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.
Definition at line 99 of file IOStream_Device.cpp.
|
virtualinherited |
Peek for the given character in device buffer. Return number of characters or EOF(-1).
[in] | c | character to peek for. |
Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.
Definition at line 105 of file IOStream_Device.cpp.
|
inline |
|
inline |
|
virtualinherited |
Write character to device.
[in] | c | character to write. |
Reimplemented in FAT16::File, HD44780, ST7565, PCD8544, MAX72XX, VLCD, UART, Textbox, IOBuffer< SIZE >, RS485, WIO, and Soft::UAT.
Definition at line 36 of file IOStream_Device.cpp.
|
virtualinherited |
Write null terminated string to device. Terminating null is not written.
[in] | s | string to write. |
Definition at line 43 of file IOStream_Device.cpp.
|
virtualinherited |
Write null terminated string from program memory to device. Terminating null is not written.
[in] | s | string in program memory to write. |
Definition at line 54 of file IOStream_Device.cpp.
|
inlinevirtual |
Read data to given buffer with given size from device.
[in] | buf | buffer to read into. |
[in] | size | number of bytes to read. |
Reimplemented from IOStream::Device.
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
virtualinherited |
Read data to given buffers in null terminated io vector.
[in] | vec | io vector with buffers to read into. |
Definition at line 157 of file IOStream_Device.cpp.
|
pure virtual |
Receive data from connection-oriented socket. The data is stored in given buffer with given maximum number of bytes. Return number of bytes or negative error code.
[in] | buf | buffer pointer. |
[in] | len | number of bytes in buffer. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
pure virtual |
Receive datagram on connectionless socket into given buffer with given maximum size. Returns zero(0) if successful with information in Datagram otherwise negative error code.
[in] | buf | buffer pointer. |
[in] | len | number of bytes in buffer. |
[in] | src | source address. |
[in] | port | source port. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
virtualinherited |
Number of bytes room (write without blocking).
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.
Definition at line 30 of file IOStream_Device.cpp.
|
inline |
|
inline |
Send given data in buffer on connectionless socket as a datagram to given destination address (dest:port). Return number of bytes sent or negative error code.
[in] | buf | buffer pointer. |
[in] | len | number of bytes in buffer. |
[in] | dest | destination address. |
[in] | port | destination port. |
|
protectedpure virtual |
Send given data in buffer on connection-oriented socket. Boolean flag progmem defined if the buffer is in program memory. Return number of bytes or negative error code.
[in] | buf | buffer pointer. |
[in] | len | number of bytes in buffer. |
[in] | progmem | program memory pointer flag. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
protectedpure virtual |
Send given data on connectionless socket as a datagram to given destination address (dest:port). Return number of bytes sent or negative error code.
[in] | buf | buffer pointer. |
[in] | len | number of bytes in buffer. |
[in] | dest | destination address. |
[in] | port | destination port. |
[in] | progmem | program memory pointer flag. |
Implemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
inline |
Send given data in program memory buffer on connection-oriented socket. Return number of bytes or negative error code.
[in] | buf | program memory pointer. |
[in] | len | number of bytes in buffer. |
|
inline |
Send given data in program memory buffer on connectionless socket as a datagram to given destination address (dest:port). Return number of bytes sent or negative error code.
[in] | buf | buffer pointer. |
[in] | len | number of bytes in buffer. |
[in] | dest | destination address. |
[in] | port | destination port. |
|
inline |
|
inlinevirtual |
Write data from buffer with given size to device.
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
Reimplemented from IOStream::Device.
Reimplemented in CC3000::Driver.
|
virtualinherited |
Write data from buffers in null terminated io vector.
[in] | vec | io vector with buffers to write. |
Definition at line 87 of file IOStream_Device.cpp.
|
inlineprotectedvirtual |
Write data from buffer with given size to device. Boolean flag progmem defined if the buffer is in program memory. Return number of bytes or negative error code.
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
[in] | progmem | program memory pointer flag. |
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, and CC3000::Driver.
|
inlinevirtual |
Write data from buffer in program memory with given size to device.
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
Reimplemented from IOStream::Device.
Reimplemented in CC3000::Driver.
|
static |
|
protectedinherited |
Blocking state
Definition at line 248 of file IOStream.hh.
|
protectedinherited |
End of line mode
Definition at line 251 of file IOStream.hh.
|
protected |
|
protected |