W5500
|
SOCKET APIs Implements file. SOCKET APIs like as Berkeley Socket APIs. More...
#include "socket.h"
Go to the source code of this file.
Macros | |
#define | SOCK_ANY_PORT_NUM 0xC000; |
#define | CHECK_SOCKNUM() |
#define | CHECK_SOCKMODE(mode) |
#define | CHECK_SOCKINIT() |
#define | CHECK_SOCKDATA() |
Functions | |
int8_t | socket (uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) |
Initializes the socket with 'sn' passed as parameter. More... | |
int8_t | close (uint8_t sn) |
Closes the socket with 'sn' passed as parameter. More... | |
int8_t | listen (uint8_t sn) |
Listens to a connection request from client. If connection request is accepted succesfully, the connection is established. Socket sn is used in passive(server) mode. More... | |
int8_t | connect (uint8_t sn, uint8_t *addr, uint16_t port) |
Request to connection to the server has addr & port passed as parameter Socket sn is used in active (client) mode. More... | |
int8_t | disconnect (uint8_t sn) |
Disconnects the tcp socket 'sn' passed as parameter. More... | |
int32_t | send (uint8_t sn, uint8_t *buf, uint16_t len) |
Send data to the connected peer in TCP socket. More... | |
int32_t | recv (uint8_t sn, uint8_t *buf, uint16_t len) |
Receive data from the connected peer. It waits for data as much as the application wants to receive. More... | |
int32_t | sendto (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port) |
Sends datagram to the peer has ip & port passed as parameter. return Success : The sent data size Fail : SOCKERR_SOCKNUM SOCKERR_SOCKMODE SOCKERR_SOCKSTATUS SOCKERR_DATALEN SOCKERR_IPINVALID SOCKERR_PORTZERO SOCKERR_SOCKCLOSED SOCKERR_TIMEOUT. More... | |
int32_t | recvfrom (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port) |
This function is an application I/F function which is used to receive the data in other then TCP mode. This function is used to receive UDP, IP_RAW and MAC_RAW mode, and handle the header as well. More... | |
SOCKET APIs Implements file. SOCKET APIs like as Berkeley Socket APIs.
Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file socket.c.
#define CHECK_SOCKNUM | ( | ) |
#define CHECK_SOCKMODE | ( | mode) |
#define CHECK_SOCKINIT | ( | ) |
#define CHECK_SOCKDATA | ( | ) |
int8_t socket | ( | uint8_t | sn, |
uint8_t | protocol, | ||
uint16_t | port, | ||
uint8_t | flag | ||
) |
Initializes the socket with 'sn' passed as parameter.
Definition at line 75 of file socket.c.
References CHECK_SOCKNUM, close(), getSn_CR(), setSn_CR(), setSn_MR(), setSn_PORT(), Sn_CR_OPEN, Sn_MR_MACRAW, Sn_MR_TCP, Sn_MR_UDP, SOCK_ANY_PORT_NUM, and SOCKERR_SOCKMODE.
int8_t close | ( | uint8_t | sn) |
Closes the socket with 'sn' passed as parameter.
Definition at line 110 of file socket.c.
References CHECK_SOCKNUM, getSn_CR(), setSn_CR(), setSn_IR(), Sn_CR_CLOSE, and SOCKOK_SUCC.
Referenced by disconnect(), listen(), recv(), recvfrom(), send(), and socket().
int8_t listen | ( | uint8_t | sn) |
Listens to a connection request from client. If connection request is accepted succesfully, the connection is established. Socket sn is used in passive(server) mode.
Definition at line 131 of file socket.c.
References CHECK_SOCKINIT, CHECK_SOCKMODE, CHECK_SOCKNUM, close(), getSn_CR(), getSn_SR(), setSn_CR(), Sn_CR_LISTEN, Sn_MR_TCP, SOCK_CLOSED, SOCK_LISTEN, SOCKERR_SOCKCLOSED, and SOCKOK_SUCC.
int8_t connect | ( | uint8_t | sn, |
uint8_t * | addr, | ||
uint16_t | port | ||
) |
Request to connection to the server has addr & port passed as parameter Socket sn is used in active (client) mode.
Definition at line 161 of file socket.c.
References CHECK_SOCKINIT, CHECK_SOCKMODE, CHECK_SOCKNUM, getSn_CR(), getSn_IR(), getSn_SR(), setSn_CR(), setSn_DIPR(), setSn_DPORT(), setSn_IR(), Sn_CR_CONNECT, Sn_IR_TIMEOUT, Sn_MR_TCP, SOCK_ESTABLISHED, SOCKERR_IPINVALID, SOCKERR_PORTZERO, SOCKERR_TIMEOUT, and SOCKOK_SUCC.
int8_t disconnect | ( | uint8_t | sn) |
Disconnects the tcp socket 'sn' passed as parameter.
Definition at line 194 of file socket.c.
References CHECK_SOCKMODE, CHECK_SOCKNUM, close(), getSn_CR(), getSn_IR(), getSn_SR(), setSn_CR(), Sn_CR_DISCON, Sn_IR_TIMEOUT, Sn_MR_TCP, SOCK_CLOSED, SOCKERR_TIMEOUT, and SOCKOK_SUCC.
int32_t send | ( | uint8_t | sn, |
uint8_t * | buf, | ||
uint16_t | len | ||
) |
Send data to the connected peer in TCP socket.
Definition at line 221 of file socket.c.
References CHECK_SOCKDATA, CHECK_SOCKMODE, CHECK_SOCKNUM, close(), getSn_CR(), getSn_IR(), getSn_SR(), getSn_TX_FSR(), getSn_TXBUF_SIZE(), setSn_CR(), setSn_IR(), Sn_CR_SEND, Sn_IR_SENDOK, Sn_IR_TIMEOUT, Sn_MR_TCP, SOCK_CLOSE_WAIT, SOCK_ESTABLISHED, SOCKERR_SOCKSTATUS, SOCKERR_TIMEOUT, and wiz_send_data().
int32_t recv | ( | uint8_t | sn, |
uint8_t * | buf, | ||
uint16_t | len | ||
) |
Receive data from the connected peer. It waits for data as much as the application wants to receive.
Definition at line 267 of file socket.c.
References CHECK_SOCKDATA, CHECK_SOCKMODE, CHECK_SOCKNUM, close(), getSn_CR(), getSn_RX_RSR(), getSn_RXBUF_SIZE(), getSn_SR(), setSn_CR(), Sn_CR_RECV, Sn_MR_TCP, SOCK_CLOSE_WAIT, SOCK_ESTABLISHED, SOCKERR_SOCKSTATUS, and wiz_recv_data().
int32_t sendto | ( | uint8_t | sn, |
uint8_t * | buf, | ||
uint16_t | len, | ||
uint8_t * | addr, | ||
uint16_t | port | ||
) |
Sends datagram to the peer has ip & port passed as parameter. return Success : The sent data size Fail : SOCKERR_SOCKNUM SOCKERR_SOCKMODE SOCKERR_SOCKSTATUS SOCKERR_DATALEN SOCKERR_IPINVALID SOCKERR_PORTZERO SOCKERR_SOCKCLOSED SOCKERR_TIMEOUT.
Definition at line 305 of file socket.c.
References CHECK_SOCKDATA, CHECK_SOCKNUM, getSn_CR(), getSn_IR(), getSn_MR(), getSn_SR(), getSn_TX_FSR(), getSn_TXBUF_SIZE(), setSn_CR(), setSn_DIPR(), setSn_DPORT(), setSn_IR(), Sn_CR_SEND, Sn_IR_SENDOK, Sn_IR_TIMEOUT, Sn_MR_MACRAW, Sn_MR_UDP, SOCK_CLOSED, SOCK_INIT, SOCK_UDP, SOCKERR_IPINVALID, SOCKERR_PORTZERO, SOCKERR_SOCKCLOSED, SOCKERR_SOCKMODE, SOCKERR_SOCKSTATUS, SOCKERR_TIMEOUT, and wiz_send_data().
int32_t recvfrom | ( | uint8_t | sn, |
uint8_t * | buf, | ||
uint16_t | len, | ||
uint8_t * | addr, | ||
uint16_t * | port | ||
) |
This function is an application I/F function which is used to receive the data in other then TCP mode. This function is used to receive UDP, IP_RAW and MAC_RAW mode, and handle the header as well.
Definition at line 360 of file socket.c.
References CHECK_SOCKDATA, CHECK_SOCKNUM, close(), getSn_CR(), getSn_MR(), getSn_RX_RSR(), getSn_SR(), setSn_CR(), Sn_CR_RECV, Sn_MR_MACRAW, Sn_MR_UDP, SOCK_CLOSED, SOCKERR_SOCKCLOSED, SOCKERR_SOCKMODE, SOCKFATAL_PACKLEN, and wiz_recv_data().