Stripped down version of Segundos NetService library (http://mbed.org/users/segundo/libraries/NetServices ). I have removed all NetServices, and all functions which had been disabled. Use this version when you need only pure TCP or UDP functions - this library compiles faster.
Dependents: christmasLights device_server pop3demo device_server_udp ... more
net.h
00001 00002 /* 00003 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy 00006 of this software and associated documentation files (the "Software"), to deal 00007 in the Software without restriction, including without limitation the rights 00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 THE SOFTWARE. 00022 */ 00023 00024 #ifndef NET_H 00025 #define NET_H 00026 00027 class NetIf; 00028 class NetTcpSocket; 00029 class NetUdpSocket; 00030 class NetDnsRequest; 00031 00032 #include <list> 00033 using std::list; 00034 00035 /* 00036 #include "host.h" 00037 #include "ipaddr.h" 00038 #include "netservice.h" 00039 #include "if/net/netif.h" 00040 #include "if/net/nettcpsocket.h" 00041 #include "if/net/netudpsocket.h" 00042 #include "if/net/netdnsrequest.h" 00043 */ 00044 00045 class Host; 00046 class NetIf; 00047 class NetTcpSocket; 00048 class NetUdpSocket; 00049 class NetDnsRequest; 00050 00051 class Net 00052 { 00053 private: 00054 Net(); 00055 ~Net(); 00056 public: 00057 static void poll(); //Poll every if & socket 00058 00059 static NetTcpSocket* tcpSocket(NetIf& netif); 00060 static NetTcpSocket* tcpSocket(); //Socket on default if 00061 static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket); 00062 00063 static NetUdpSocket* udpSocket(NetIf& netif); 00064 static NetUdpSocket* udpSocket(); //Socket on default if 00065 static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket); 00066 00067 static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif); 00068 static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if 00069 00070 static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif); 00071 static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if 00072 00073 static void setDefaultIf(NetIf& netif); //Deprecated 00074 static void setDefaultIf(NetIf* pIf); 00075 static NetIf* getDefaultIf(); 00076 00077 protected: 00078 friend class NetIf; 00079 friend class NetTcpSocket; 00080 friend class NetUdpSocket; 00081 00082 static void registerIf(NetIf* pIf); 00083 static void unregisterIf(NetIf* pIf); 00084 00085 static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket); 00086 static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket); 00087 00088 static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket); 00089 static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket); 00090 00091 private: 00092 static Net& net(); //Return inst of singleton 00093 00094 NetIf* m_defaultIf; 00095 00096 list<NetIf*> m_lpIf; 00097 list<NetTcpSocket*> m_lpNetTcpSocket; 00098 list<NetUdpSocket*> m_lpNetUdpSocket; 00099 }; 00100 00101 #endif
Generated on Tue Jul 12 2022 19:43:59 by
![doxygen](doxygen.png)