/************************************************************************
 * AUTHOR: NiuJiuRu
 * FILENAME: swudp.h
 * DESCRIPTION: UDP socket
 * NOTE:
 * HISTORY:
 * 1, [2010-11-30] created by NiuJiuRu
 ***********************************************************************/
#ifndef __SWUDP_H__
#define __SWUDP_H__

#ifdef __cplusplus
extern "C"
{
#endif

/* 创建一个udp socket */
int sw_udp_socket();

/* 关闭一个udp socket */
void sw_udp_close(int skt);

/* 绑定接收地址和端口 */
int sw_udp_bind(int skt, unsigned int ip, unsigned short port);

/* 加入一个多播组 */
int sw_udp_join(int skt, unsigned int ip);

/* 退出一个多播组 */
int sw_udp_drop(int skt, unsigned int ip);

/* 发送数据 */
int sw_udp_send(int skt, unsigned int ip, unsigned short port, char *buf, int send_len);

/* 接收数据 */
int sw_udp_recv(int skt, unsigned int *ip, unsigned short *port, char *buf, int buf_size);

/* 配置udp socket */
int sw_udp_ioctl(int skt, int type, unsigned long *val);

/* 检测udp socket的状态, timeout单位为ms */
int sw_udp_select(int skt, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int timeout);

#ifdef __cplusplus
}
#endif

#endif /*__SWUDP_H__*/
