picoos-net
1.xxxx
|
Functions | |
void | netInit (void) |
UosFile * | netSockAlloc (NetSockState initialState) |
void | netSockFree (UosFile *sock) |
UosFile * | netSockCreateUDP (uip_ipaddr_t *ip, int port) |
UosFile * | netSockCreateTCPServer (int port) |
int | netSockBind (UosFile *sock, int port) |
void | netSockListen (UosFile *sock) |
UosFile * | netSockAccept (UosFile *listenSocket, uip_ipaddr_t *peer) |
UosFile * | netSockCreateTCP (uip_ipaddr_t *ip, int port) |
int | netSockConnect (UosFile *sock, uip_ipaddr_t *ip, int port) |
void | netSockAcceptHookSet (NetSockAcceptHook hook) |
int | netSockTimeout (UosFile *sock, UINT_t timeout) |
int | netSockRead (UosFile *sock, void *data, uint16_t max, uint16_t timeout) |
int | netSockReadLine (UosFile *sock, void *data, uint16_t max, uint16_t timeout) |
void | telnetInit (NetTelnet *state, int sock) |
void | telnetWrite (NetTelnet *conn, char *data) |
void | telnetFlush (NetTelnet *conn) |
int | telnetReadLine (NetTelnet *conn, char *data, int max, int timeout) |
void netInit | ( | void | ) |
Initialize socket layer. Before calling this Ethernet and IP address setup must be performed using uip_setethaddr and uip_sethostaddr.
After initializing network interface function starts a thread for main loop, which performs necessary uIP services for socket layer.
UosFile* netSockAlloc | ( | NetSockState | initialState | ) |
Allocate a new socket descriptor by searching for a free one in socket table.
void netSockFree | ( | UosFile * | sock | ) |
Free a new socket descriptor.
UosFile* netSockCreateUDP | ( | uip_ipaddr_t * | ip, |
int | port | ||
) |
Create new UDP socket. This is the same as netSockUdpCreate() in previous versions.
UosFile* netSockCreateTCPServer | ( | int | port | ) |
Create a server socket, for listening incoming connections. This is same as netSockServerCreate in previous versions.
int netSockBind | ( | UosFile * | sock, |
int | port | ||
) |
Bind server socket to given port before listening on it.
void netSockListen | ( | UosFile * | sock | ) |
Start listening for incoming connections. Port is set during netSockServerCreate().
UosFile* netSockAccept | ( | UosFile * | listenSocket, |
uip_ipaddr_t * | peer | ||
) |
Accept new incoming connection.
UosFile* netSockCreateTCP | ( | uip_ipaddr_t * | ip, |
int | port | ||
) |
Create new client connection to given IP address and port. This replaces netSockConnect call in previous library versions.
int netSockConnect | ( | UosFile * | sock, |
uip_ipaddr_t * | ip, | ||
int | port | ||
) |
Connect socket (udp or tcp) to given IP and port. This works like BSD connect() now. To get functionality similar to previous library versions, use netSockCrateTCP().
void netSockAcceptHookSet | ( | NetSockAcceptHook | hook | ) |
Set accept hook function to handling incoming connections. After accept hook is called by main loop it is responsible for handling the connection. Usually a new pico]OS thread is created to process data.
Accept hook should not block.
Accept hook provides functionality that is similar to unix accept().
int netSockTimeout | ( | UosFile * | sock, |
UINT_t | timeout | ||
) |
Set read timeout for socket.
int netSockRead | ( | UosFile * | sock, |
void * | data, | ||
uint16_t | max, | ||
uint16_t | timeout | ||
) |
Read data from socket. Similar to unix read(). Function blocks until data is available.
int netSockReadLine | ( | UosFile * | sock, |
void * | data, | ||
uint16_t | max, | ||
uint16_t | timeout | ||
) |
Read a line (terminated by CR or NL) from socket.
void telnetInit | ( | NetTelnet * | state, |
int | sock | ||
) |
Initialize telnet protocol state machine for given socket connection.
void telnetWrite | ( | NetTelnet * | conn, |
char * | data | ||
) |
Write data using telnet protocol.
void telnetFlush | ( | NetTelnet * | conn | ) |
Flush data. Causes immediate sending of data that has been buffered.
int telnetReadLine | ( | NetTelnet * | conn, |
char * | data, | ||
int | max, | ||
int | timeout | ||
) |
Read a line from socket using telnet protocol. Handly when writing CLI servers.