00001 #ifndef __UDP_H 00002 #define __UDP_H 00003 #include <netinet/in.h> 00004 00005 struct udp_struct 00006 { 00007 int s; 00008 struct sockaddr_in si_me; 00009 struct sockaddr_in si_other; 00010 socklen_t slen; 00011 }; 00012 00013 int udpClient_Init(udp_struct *udp, const char* host, int port); 00014 int udpClient_Send(udp_struct *udp, char* buf, int len); 00015 void udpClient_Close(udp_struct *udp); 00016 00017 int udpServer_Init(udp_struct *udp, int port, int blocking); 00018 //returns size of packet received or -1 on error 00019 int udpServer_Receive(udp_struct *udp, char* buf, int len); 00020 void udpServer_Close(udp_struct *udp); 00021 #endif