SWILIB API (ELKA)    
Loading...
Searching...
No Matches
socket.h File Reference
#include "base.h"
#include "gprs.h"

Go to the source code of this file.

Data Structures

struct  in_addr
 Internet address (a structure for historical reasons) More...
 
struct  sockaddr
 Socket address, generic. More...
 
struct  sockaddr_in
 Socket address, internet style. More...
 
struct  hostent
 DNS response. More...
 

Macros

#define INADDR_ANY   (uint32_t) 0x00000000
 Definitions of bits in internet address integers.
 
#define INADDR_BROADCAST   (uint32_t) 0xffffffff
 
#define INET_ADDRSTRLEN   16
 Maximum length of the IPv4 address.
 
#define MAX_IPv4_STR_LEN   16
 Maximum length of the IPv4 address.
 
#define MAX_IPv6_STR_LEN   64
 Maximum length of the IPv6 address.
 
#define IP_ADDR(A, B, C, D)   (((unsigned long)A << 24) | ((unsigned long)B << 16) | ((unsigned long) C << 8) | ((unsigned long) D << 0))
 Helper for creating IP address.
 

Typedefs

typedef uint16_t in_port_t
 Port value.
 
typedef uint16_t sa_family_t
 Address family.
 
typedef uint32_t in_addr_t
 Internet address.
 
typedef uint32_t socklen_t
 Socket address length type definition.
 
typedef struct sockaddr SOCK_ADDR
 ELF's backward compatibility.
 
typedef struct sockaddr_in SOCKADDR_IN
 Windows-style.
 
typedef struct sockaddr SOCKADDR
 Windows-style.
 
typedef struct hostent HOSTENT
 Windows-style.
 

Enumerations

enum  SockProtocolID {
  IPPROTO_IP = 0 ,
  IPPROTO_TCP = 6 ,
  IPPROTO_UDP = 17 ,
  IPPROTO_MAX = 18
}
 Internet protocols. More...
 
enum  SockTypeID {
  SOCK_DGRAM = 0 ,
  SOCK_STREAM = 1
}
 Socket types. More...
 
enum  SockFamilyID {
  AF_UNSPEC = 0 ,
  AF_INET = 1 ,
  AF_MAX = 2
}
 Socket family types. More...
 
enum  SockShutdownTypeID {
  SHUT_RD = 0 ,
  SHUT_WR = 1 ,
  SHUT_RDWR = 2
}
 Socket shutdown types. More...
 

Functions

int async_gethostbyname (const char *name, void *response, int *req_id)
 Resolve domain name.
 
uint32_t str2ip (const char *ip)
 Convert the string IP address to the numeric format.
 
in_addr_t inet_addr (const char *ip)
 Convert the string IP address to the numeric format.
 
uint16_t htons (uint16_t p)
 Convert host to network order (unsigned short).
 
uint32_t htonl (uint32_t p)
 Convert host to network order (unsigned int).
 
static uint16_t ntohs (uint16_t p)
 Convert network to host order.
 
static uint32_t ntohl (uint32_t p)
 
int socket (int domain, int type, int protocol)
 
int connect (int socket, const struct sockaddr *address, socklen_t address_len)
 Connect socket to the address.
 
int bind (int socket, const struct sockaddr *address, socklen_t address_len)
 Bind socket to the address.
 
int shutdown (int socket, int how)
 Shutdown.
 
int recv (int socket, void *buf, int len, int flags)
 Receive data on a socket.
 
int send (int socket, const void *buf, int len, int flags)
 Send a message on a socket.
 
int available0 (int socket)
 Get available bytes for reading in the socket.
 
int * socklasterr (void)
 Pointer to the last socket error.
 
int closesocket (int socket)
 Close socket descriptor.
 
struct hostent * gethostbyname (const char *name)
 Resolve a host name synchronously.
 
int getsockname (int sock, SOCK_ADDR *addr, int *len)
 Read the local address of a socket.
 
int getpeername (int sock, SOCK_ADDR *addr, int *len)
 Read the remote address of a connected socket.
 
int setsockopt (int sock, int level, int option, const void *value, int len)
 Set a socket option.
 
int getsockopt (int sock, int level, int option, void *value, int *len)
 Read a socket option.
 
int ioctlsocket (int sock, int cmd, void *arg)
 Apply a socket control command; read socklasterr for errors.
 
int listen (int sock, int backlog)
 Start listening for incoming TCP connections.
 
int ENIP_GetNativeSocket (int sock, ENIP_SOCKET **native)
 Look up the native ENIP object for a socket descriptor.