NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Revision:
5:dd63a1e02b1b
Parent:
0:632c9925f013
Child:
6:b7dd7cde8ad2
--- a/api/UDPSocket.h	Fri Jul 09 14:46:47 2010 +0000
+++ b/api/UDPSocket.h	Tue Jul 27 15:59:42 2010 +0000
@@ -27,41 +27,70 @@
 #include "if/net/net.h"
 //Essentially it is a safe interface to NetUdpSocket
 
+///UDP Socket Errors
 enum UDPSocketErr
 {
   __UDPSOCKET_MIN = -0xFFFF,
-  UDPSOCKET_SETUP, //NetUdpSocket not properly configured
-  UDPSOCKET_IF, //If has problems, does not exist or is not initialized
-  UDPSOCKET_MEM, //Not enough mem
-  UDPSOCKET_INUSE, //If/Port is in use
+  UDPSOCKET_SETUP, ///UDPSocket not properly configured
+  UDPSOCKET_IF, ///Interface has problems, does not exist or is not initialized
+  UDPSOCKET_MEM, ///Not enough mem
+  UDPSOCKET_INUSE, ///Interface / Port is in use
 //...
   UDPSOCKET_OK = 0
 };
 
+///UDP Socket Event(s)
 enum UDPSocketEvent //Only one lonely event here... but who knows, maybe some day there'll be another one!
 {
-  UDPSOCKET_READABLE, //Data in buf
+  UDPSOCKET_READABLE, ///Data in buf
 };
 
-
+///This is a simple UDP Socket class
+/**
+  This class exposes an API to deal with UDP Sockets
+*/
 class UDPSocket
 {
 public:
+  ///Creates a new socket
   UDPSocket();
   ~UDPSocket(); //close()
   
+  ///Binds the socket to (local) host (or TODO: a multicast address)
   UDPSocketErr bind(const Host& me);
   
+  ///Sends data
+  /*
+  @param pHost : host to send data to
+  @return a negative error code or the number of bytes transmitted
+  */
   int /*if < 0 : UDPSocketErr*/ sendto(const char* buf, int len, Host* pHost);
+  
+  ///Receives data
+  /*
+  @param pHost : host from which this piece of data comes from
+  @return a negative error code or the number of bytes received
+  */
   int /*if < 0 : UDPSocketErr*/ recvfrom(char* buf, int len, Host* pHost);
 
   /* TODO NTH : printf / scanf helpers that call send/recv */
 
+  ///Closes socket
   UDPSocketErr close();
 
+  //Callbacks
+  ///Setups callback
+  /**
+  @param pMethod : callback function
+  */  
+  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  
   class CDummy;
-  //Callbacks
-  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  ///Setups callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnEvent( T* pItem, void (T::*pMethod)(UDPSocketEvent) )
   {
@@ -69,7 +98,8 @@
     m_pCbMeth = (void (CDummy::*)(UDPSocketEvent)) pMethod;
   }
   
-  void resetOnEvent(); //Disable callback
+  ///Disables callback
+  void resetOnEvent();
 
 protected:
   void onNetUdpSocketEvent(NetUdpSocketEvent e);