Nut/OS  4.10.3
API Reference
socket.h File Reference

UDP and TCP socket interface definitions. More...

#include <cfg/udp.h>
#include <compiler.h>
#include <sys/sock_var.h>
Include dependency graph for socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SOCK_STREAM   1
 Stream socket.
#define SOCK_DGRAM   2
 Datagram socket.
#define SOCK_RAW   3
 Raw-protocol interface.
#define SO_DEBUG   0x0001
 Turn on debugging info recording.
#define SO_ACCEPTCONN   0x0002
 Socket has had listen()
#define SO_REUSEADDR   0x0004
 Allow local address reuse.
#define SO_KEEPALIVE   0x0008
 Keep connections alive.
#define SO_DONTROUTE   0x0010
 Just use interface addresses.
#define SO_BROADCAST   0x0020
 Permit sending of broadcast msgs.
#define SO_USELOOPBACK   0x0040
 Bypass hardware when possible.
#define SO_LINGER   0x0080
 Linger on close if data present.
#define SO_OOBINLINE   0x0100
 Leave received OOB data in line.
#define SO_REUSEPORT   0x0200
 Allow local address & port reuse.
#define SO_SNDBUF   0x1001
 Send buffer size.
#define SO_RCVBUF   0x1002
 Receive buffer size.
#define SO_SNDLOWAT   0x1003
 Send low-water mark.
#define SO_RCVLOWAT   0x1004
 Receive low-water mark.
#define SO_SNDTIMEO   0x1005
 Send timeout.
#define SO_RCVTIMEO   0x1006
 Receive timeout.
#define SO_ERROR   0x1007
 Get error status and clear.
#define SO_TYPE   0x1008
 Get socket type.
#define AF_INET   2
 internetwork: UDP, TCP, etc.
#define _SYS_SOCKET_H_

Functions

TCPSOCKETNutTcpCreateSocket (void)
 Create a TCP socket.
int NutTcpSetSockOpt (TCPSOCKET *sock, int optname, CONST void *optval, int optlen)
 Set value of a TCP socket option.
int NutTcpGetSockOpt (TCPSOCKET *sock, int optname, void *optval, int optlen)
 Get a TCP socket option value.
int NutTcpConnect (TCPSOCKET *sock, uint32_t addr, uint16_t port)
 Connect to a remote socket.
int NutTcpAccept (TCPSOCKET *sock, uint16_t port)
 Wait for incoming connect from a remote socket.
int NutTcpInput (NUTDEVICE *dev, NETBUF *nb)
 Process incoming TCP segments from IP layer.
int NutTcpSend (TCPSOCKET *sock, CONST void *data, int len)
 Send data on a connected TCP socket.
int NutTcpSend_P (TCPSOCKET *sock, PGM_P data, int len)
int NutTcpCloseSocket (TCPSOCKET *sock)
 Close TCP socket.
void NutTcpDestroySocket (TCPSOCKET *sock)
 Destroy a previously allocated socket.
int NutTcpReceive (TCPSOCKET *sock, void *data, int size)
 Receive data on a connected TCP socket.
TCPSOCKETNutTcpFindSocket (uint16_t lport, uint16_t rport, uint32_t raddr)
 Find a matching socket.
int NutTcpError (TCPSOCKET *sock)
 Return specific code of the last error.
int NutTcpAbortSocket (TCPSOCKET *sock, uint16_t last_error)
 Closes socket with error.
void NutTcpDiscardBuffers (TCPSOCKET *sock)
int NutTcpDeviceRead (TCPSOCKET *sock, void *buffer, int size)
 Read from virtual socket device.
int NutTcpDeviceWrite (TCPSOCKET *sock, CONST void *buffer, int size)
 Write to a socket.
int NutTcpDeviceWrite_P (TCPSOCKET *sock, PGM_P buffer, int size)
 Write to device.
int NutTcpDeviceIOCtl (TCPSOCKET *sock, int cmd, void *param)
 Driver control function.
int NutTcpDeviceClose (TCPSOCKET *sock)
UDPSOCKETNutUdpCreateSocket (uint16_t port)
 Create a UDP socket.
int NutUdpSendTo (UDPSOCKET *sock, uint32_t addr, uint16_t port, void *data, int len)
 Send a UDP datagram.
int NutUdpReceiveFrom (UDPSOCKET *sock, uint32_t *addr, uint16_t *port, void *data, int size, uint32_t timeout)
 Receive a UDP datagram.
int NutUdpDestroySocket (UDPSOCKET *sock)
 Close UDP socket.
UDPSOCKETNutUdpFindSocket (uint16_t port)
 Find a matching socket.
int NutUdpSetSockOpt (UDPSOCKET *sock, int optname, CONST void *optval, int optlen)
 Set value of a UDP socket option.
int NutUdpGetSockOpt (UDPSOCKET *sock, int optname, void *optval, int optlen)
 Get a UDP socket option value.

Detailed Description

UDP and TCP socket interface definitions.

Definition in file socket.h.


Define Documentation

#define SOCK_STREAM   1

Stream socket.

Definition at line 141 of file socket.h.

#define SOCK_DGRAM   2

Datagram socket.

Definition at line 142 of file socket.h.

#define SOCK_RAW   3

Raw-protocol interface.

Definition at line 143 of file socket.h.

#define SO_DEBUG   0x0001

Turn on debugging info recording.

Definition at line 148 of file socket.h.

#define SO_ACCEPTCONN   0x0002

Socket has had listen()

Definition at line 149 of file socket.h.

#define SO_REUSEADDR   0x0004

Allow local address reuse.

Definition at line 150 of file socket.h.

#define SO_KEEPALIVE   0x0008

Keep connections alive.

Definition at line 151 of file socket.h.

#define SO_DONTROUTE   0x0010

Just use interface addresses.

Definition at line 152 of file socket.h.

#define SO_BROADCAST   0x0020

Permit sending of broadcast msgs.

Definition at line 153 of file socket.h.

#define SO_USELOOPBACK   0x0040

Bypass hardware when possible.

Definition at line 154 of file socket.h.

#define SO_LINGER   0x0080

Linger on close if data present.

Definition at line 155 of file socket.h.

#define SO_OOBINLINE   0x0100

Leave received OOB data in line.

Definition at line 156 of file socket.h.

#define SO_REUSEPORT   0x0200

Allow local address & port reuse.

Definition at line 157 of file socket.h.

#define SO_SNDBUF   0x1001

Send buffer size.

Definition at line 162 of file socket.h.

#define SO_RCVBUF   0x1002
#define SO_SNDLOWAT   0x1003

Send low-water mark.

Definition at line 164 of file socket.h.

#define SO_RCVLOWAT   0x1004

Receive low-water mark.

Definition at line 165 of file socket.h.

#define SO_SNDTIMEO   0x1005

Send timeout.

Definition at line 166 of file socket.h.

Referenced by NutTcpGetSockOpt(), and NutTcpSetSockOpt().

#define SO_RCVTIMEO   0x1006

Receive timeout.

Examples:
ftpd/ftpserv.c.

Definition at line 167 of file socket.h.

Referenced by NutSmtpConnect().

#define SO_ERROR   0x1007

Get error status and clear.

Definition at line 168 of file socket.h.

#define SO_TYPE   0x1008

Get socket type.

Definition at line 169 of file socket.h.

#define AF_INET   2

internetwork: UDP, TCP, etc.

Definition at line 174 of file socket.h.

#define _SYS_SOCKET_H_

Definition at line 181 of file socket.h.


Function Documentation

int NutTcpSend_P ( TCPSOCKET sock,
PGM_P  data,
int  len 
)
int NutTcpDeviceClose ( TCPSOCKET sock)