mUPnP for C
socket.h File Reference
#include <mupnp/typedef.h>
#include <mupnp/util/string.h>

Data Structures

struct  _mUpnpSocket
 
struct  _mUpnpDatagramPacket
 

Macros

#define MUPNP_NET_SOCKET_NONE   0
 
#define MUPNP_NET_SOCKET_STREAM   0x01
 
#define MUPNP_NET_SOCKET_DGRAM   0x02
 
#define MUPNP_NET_SOCKET_CLIENT   1
 
#define MUPNP_NET_SOCKET_SERVER   2
 
#define MUPNP_NET_SOCKET_MAXHOST   32
 
#define MUPNP_NET_SOCKET_MAXSERV   32
 
#define MUPNP_SOCKET_LF   '\n'
 
#define MUPNP_NET_SOCKET_DGRAM_RECV_BUFSIZE   512
 
#define MUPNP_NET_SOCKET_DGRAM_ANCILLARY_BUFSIZE   512
 
#define MUPNP_NET_SOCKET_MULTICAST_DEFAULT_TTL   4
 
#define MUPNP_NET_SOCKET_AUTO_IP_NET   0xa9fe0000
 
#define MUPNP_NET_SOCKET_AUTO_IP_MASK   0xffff0000
 
#define mupnp_socket_stream_new()
 
#define mupnp_socket_dgram_new()
 
#define mupnp_socket_getid(socket)
 
#define mupnp_socket_settype(socket, value)
 
#define mupnp_socket_gettype(socket)
 
#define mupnp_socket_issocketstream(socket)
 
#define mupnp_socket_isdatagramstream(socket)
 
#define mupnp_socket_setdirection(socket, value)
 
#define mupnp_socket_getdirection(socket)
 
#define mupnp_socket_isclient(socket)
 
#define mupnp_socket_isserver(socket)
 
#define mupnp_socket_setaddress(socket, value)
 
#define mupnp_socket_setport(socket, value)
 
#define mupnp_socket_getaddress(socket)
 
#define mupnp_socket_getport(socket)
 
#define mupnp_socket_datagram_packet_setdata(dgmPkt, value)
 
#define mupnp_socket_datagram_packet_getdata(dgmPkt)
 
#define mupnp_socket_datagram_packet_setlocaladdress(dgmPkt, addr)
 
#define mupnp_socket_datagram_packet_getlocaladdress(dgmPkt)
 
#define mupnp_socket_datagram_packet_setlocalport(dgmPkt, port)
 
#define mupnp_socket_datagram_packet_getlocalport(dgmPkt)
 
#define mupnp_socket_datagram_packet_setremoteaddress(dgmPkt, addr)
 
#define mupnp_socket_datagram_packet_getremoteaddress(dgmPkt)
 
#define mupnp_socket_datagram_packet_setremoteport(dgmPkt, port)
 
#define mupnp_socket_datagram_packet_getremoteport(dgmPkt)
 

Typedefs

typedef int SOCKET
 
typedef struct _mUpnpSocket mUpnpSocket
 
typedef struct _mUpnpSocket mUpnpSocketList
 
typedef struct _mUpnpDatagramPacket mUpnpDatagramPacket
 

Functions

void mupnp_socket_startup (void)
 
void mupnp_socket_cleanup (void)
 
mUpnpSocketmupnp_socket_new (int type)
 
bool mupnp_socket_delete (mUpnpSocket *socket)
 
void mupnp_socket_setid (mUpnpSocket *socket, SOCKET value)
 
bool mupnp_socket_isbound (mUpnpSocket *socket)
 
bool mupnp_socket_close (mUpnpSocket *socket)
 
bool mupnp_socket_listen (mUpnpSocket *socket)
 
bool mupnp_socket_bind (mUpnpSocket *sock, int bindPort, const char *bindAddr, bool bindFlag, bool reuseFlag)
 
bool mupnp_socket_accept (mUpnpSocket *sock, mUpnpSocket *clientSock)
 
bool mupnp_socket_connect (mUpnpSocket *sock, const char *addr, int port)
 
ssize_t mupnp_socket_read (mUpnpSocket *sock, char *buffer, size_t bufferLen)
 
size_t mupnp_socket_write (mUpnpSocket *sock, const char *buffer, size_t bufferLen)
 
ssize_t mupnp_socket_readline (mUpnpSocket *sock, char *buffer, size_t bufferLen)
 
size_t mupnp_socket_skip (mUpnpSocket *sock, size_t skipLen)
 
size_t mupnp_socket_sendto (mUpnpSocket *sock, const char *addr, int port, const char *data, size_t dataeLen)
 
ssize_t mupnp_socket_recv (mUpnpSocket *sock, mUpnpDatagramPacket *dgmPkt)
 
int mupnp_socket_getlasterror (void)
 
bool mupnp_socket_joingroup (mUpnpSocket *sock, const char *mcastAddr, const char *ifAddr)
 
bool mupnp_socket_setreuseaddress (mUpnpSocket *socket, bool flag)
 
bool mupnp_socket_setmulticastttl (mUpnpSocket *sock, int ttl)
 
bool mupnp_socket_settimeout (mUpnpSocket *sock, int sec)
 
mUpnpDatagramPacketmupnp_socket_datagram_packet_new (void)
 
void mupnp_socket_datagram_packet_delete (mUpnpDatagramPacket *dgmPkt)
 
void mupnp_socket_datagram_packet_copy (mUpnpDatagramPacket *dstDgmPkt, mUpnpDatagramPacket *srcDgmPkt)
 

Macro Definition Documentation

◆ MUPNP_NET_SOCKET_AUTO_IP_MASK

#define MUPNP_NET_SOCKET_AUTO_IP_MASK   0xffff0000

◆ MUPNP_NET_SOCKET_AUTO_IP_NET

#define MUPNP_NET_SOCKET_AUTO_IP_NET   0xa9fe0000

◆ MUPNP_NET_SOCKET_CLIENT

#define MUPNP_NET_SOCKET_CLIENT   1

◆ MUPNP_NET_SOCKET_DGRAM

#define MUPNP_NET_SOCKET_DGRAM   0x02

◆ MUPNP_NET_SOCKET_DGRAM_ANCILLARY_BUFSIZE

#define MUPNP_NET_SOCKET_DGRAM_ANCILLARY_BUFSIZE   512

◆ MUPNP_NET_SOCKET_DGRAM_RECV_BUFSIZE

#define MUPNP_NET_SOCKET_DGRAM_RECV_BUFSIZE   512

◆ MUPNP_NET_SOCKET_MAXHOST

#define MUPNP_NET_SOCKET_MAXHOST   32

◆ MUPNP_NET_SOCKET_MAXSERV

#define MUPNP_NET_SOCKET_MAXSERV   32

◆ MUPNP_NET_SOCKET_MULTICAST_DEFAULT_TTL

#define MUPNP_NET_SOCKET_MULTICAST_DEFAULT_TTL   4

◆ MUPNP_NET_SOCKET_NONE

#define MUPNP_NET_SOCKET_NONE   0

◆ MUPNP_NET_SOCKET_SERVER

#define MUPNP_NET_SOCKET_SERVER   2

◆ MUPNP_NET_SOCKET_STREAM

#define MUPNP_NET_SOCKET_STREAM   0x01

◆ mupnp_socket_datagram_packet_getdata

#define mupnp_socket_datagram_packet_getdata ( dgmPkt)
Value:
mupnp_string_getvalue(dgmPkt->data)
char * mupnp_string_getvalue(mUpnpString *str)
Definition string.c:177

◆ mupnp_socket_datagram_packet_getlocaladdress

#define mupnp_socket_datagram_packet_getlocaladdress ( dgmPkt)
Value:
mupnp_string_getvalue(dgmPkt->localAddress)

◆ mupnp_socket_datagram_packet_getlocalport

#define mupnp_socket_datagram_packet_getlocalport ( dgmPkt)
Value:
(dgmPkt->localPort)

◆ mupnp_socket_datagram_packet_getremoteaddress

#define mupnp_socket_datagram_packet_getremoteaddress ( dgmPkt)
Value:
mupnp_string_getvalue(dgmPkt->remoteAddress)

◆ mupnp_socket_datagram_packet_getremoteport

#define mupnp_socket_datagram_packet_getremoteport ( dgmPkt)
Value:
(dgmPkt->remotePort)

◆ mupnp_socket_datagram_packet_setdata

#define mupnp_socket_datagram_packet_setdata ( dgmPkt,
value )
Value:
mupnp_string_setvalue(dgmPkt->data, value)
void mupnp_string_setvalue(mUpnpString *str, const char *value)
Definition string.c:84

◆ mupnp_socket_datagram_packet_setlocaladdress

#define mupnp_socket_datagram_packet_setlocaladdress ( dgmPkt,
addr )
Value:
mupnp_string_setvalue(dgmPkt->localAddress, addr)

◆ mupnp_socket_datagram_packet_setlocalport

#define mupnp_socket_datagram_packet_setlocalport ( dgmPkt,
port )
Value:
(dgmPkt->localPort = port)

◆ mupnp_socket_datagram_packet_setremoteaddress

#define mupnp_socket_datagram_packet_setremoteaddress ( dgmPkt,
addr )
Value:
mupnp_string_setvalue(dgmPkt->remoteAddress, addr)

◆ mupnp_socket_datagram_packet_setremoteport

#define mupnp_socket_datagram_packet_setremoteport ( dgmPkt,
port )
Value:
(dgmPkt->remotePort = port)

◆ mupnp_socket_dgram_new

#define mupnp_socket_dgram_new ( )
Value:
#define MUPNP_NET_SOCKET_DGRAM
Definition socket.h:33
mUpnpSocket * mupnp_socket_new(int type)
Definition socket.c:209

◆ mupnp_socket_getaddress

#define mupnp_socket_getaddress ( socket)
Value:
mupnp_string_getvalue(socket->ipaddr)

◆ mupnp_socket_getdirection

#define mupnp_socket_getdirection ( socket)
Value:
(socket->direction)

◆ mupnp_socket_getid

#define mupnp_socket_getid ( socket)
Value:
(socket->id)

◆ mupnp_socket_getport

#define mupnp_socket_getport ( socket)
Value:
(socket->port)

◆ mupnp_socket_gettype

#define mupnp_socket_gettype ( socket)
Value:
(socket->type)

◆ mupnp_socket_isclient

#define mupnp_socket_isclient ( socket)
Value:
((socket->direction == MUPNP_NET_SOCKET_CLIENT) ? true : false)
#define MUPNP_NET_SOCKET_CLIENT
Definition socket.h:35
#define true
Definition typedef.h:63

◆ mupnp_socket_isdatagramstream

#define mupnp_socket_isdatagramstream ( socket)
Value:
((socket->type & MUPNP_NET_SOCKET_DGRAM) ? true : false)

◆ mupnp_socket_isserver

#define mupnp_socket_isserver ( socket)
Value:
((socket->direction == MUPNP_NET_SOCKET_SERVER) ? true : false)
#define MUPNP_NET_SOCKET_SERVER
Definition socket.h:36

◆ mupnp_socket_issocketstream

#define mupnp_socket_issocketstream ( socket)
Value:
((socket->type & MUPNP_NET_SOCKET_STREAM) ? true : false)
#define MUPNP_NET_SOCKET_STREAM
Definition socket.h:32

◆ MUPNP_SOCKET_LF

#define MUPNP_SOCKET_LF   '\n'

◆ mupnp_socket_setaddress

#define mupnp_socket_setaddress ( socket,
value )
Value:
mupnp_string_setvalue(socket->ipaddr, value)

◆ mupnp_socket_setdirection

#define mupnp_socket_setdirection ( socket,
value )
Value:
(socket->direction = value)

◆ mupnp_socket_setport

#define mupnp_socket_setport ( socket,
value )
Value:
(socket->port = value)

◆ mupnp_socket_settype

#define mupnp_socket_settype ( socket,
value )
Value:
(socket->type = value)

◆ mupnp_socket_stream_new

#define mupnp_socket_stream_new ( )

Typedef Documentation

◆ mUpnpDatagramPacket

◆ mUpnpSocket

typedef struct _mUpnpSocket mUpnpSocket

◆ mUpnpSocketList

typedef struct _mUpnpSocket mUpnpSocketList

◆ SOCKET

typedef int SOCKET

Function Documentation

◆ mupnp_socket_accept()

bool mupnp_socket_accept ( mUpnpSocket * sock,
mUpnpSocket * clientSock )

◆ mupnp_socket_bind()

bool mupnp_socket_bind ( mUpnpSocket * sock,
int bindPort,
const char * bindAddr,
bool bindFlag,
bool reuseFlag )

◆ mupnp_socket_cleanup()

void mupnp_socket_cleanup ( void )

◆ mupnp_socket_close()

bool mupnp_socket_close ( mUpnpSocket * socket)

◆ mupnp_socket_connect()

bool mupnp_socket_connect ( mUpnpSocket * sock,
const char * addr,
int port )

◆ mupnp_socket_datagram_packet_copy()

void mupnp_socket_datagram_packet_copy ( mUpnpDatagramPacket * dstDgmPkt,
mUpnpDatagramPacket * srcDgmPkt )

◆ mupnp_socket_datagram_packet_delete()

void mupnp_socket_datagram_packet_delete ( mUpnpDatagramPacket * dgmPkt)

◆ mupnp_socket_datagram_packet_new()

mUpnpDatagramPacket * mupnp_socket_datagram_packet_new ( void )

◆ mupnp_socket_delete()

bool mupnp_socket_delete ( mUpnpSocket * socket)

◆ mupnp_socket_getlasterror()

int mupnp_socket_getlasterror ( void )

◆ mupnp_socket_isbound()

bool mupnp_socket_isbound ( mUpnpSocket * socket)

◆ mupnp_socket_joingroup()

bool mupnp_socket_joingroup ( mUpnpSocket * sock,
const char * mcastAddr,
const char * ifAddr )

◆ mupnp_socket_listen()

bool mupnp_socket_listen ( mUpnpSocket * socket)

◆ mupnp_socket_new()

mUpnpSocket * mupnp_socket_new ( int type)

◆ mupnp_socket_read()

ssize_t mupnp_socket_read ( mUpnpSocket * sock,
char * buffer,
size_t bufferLen )

◆ mupnp_socket_readline()

ssize_t mupnp_socket_readline ( mUpnpSocket * sock,
char * buffer,
size_t bufferLen )

◆ mupnp_socket_recv()

ssize_t mupnp_socket_recv ( mUpnpSocket * sock,
mUpnpDatagramPacket * dgmPkt )

◆ mupnp_socket_sendto()

size_t mupnp_socket_sendto ( mUpnpSocket * sock,
const char * addr,
int port,
const char * data,
size_t dataeLen )

◆ mupnp_socket_setid()

void mupnp_socket_setid ( mUpnpSocket * socket,
SOCKET value )

◆ mupnp_socket_setmulticastttl()

bool mupnp_socket_setmulticastttl ( mUpnpSocket * sock,
int ttl )

◆ mupnp_socket_setreuseaddress()

bool mupnp_socket_setreuseaddress ( mUpnpSocket * socket,
bool flag )

◆ mupnp_socket_settimeout()

bool mupnp_socket_settimeout ( mUpnpSocket * sock,
int sec )

◆ mupnp_socket_skip()

size_t mupnp_socket_skip ( mUpnpSocket * sock,
size_t skipLen )

◆ mupnp_socket_startup()

void mupnp_socket_startup ( void )

◆ mupnp_socket_write()

size_t mupnp_socket_write ( mUpnpSocket * sock,
const char * buffer,
size_t bufferLen )