X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finet.h;fp=source%2Finet.h;h=1092bc1a8372fbd6e473ebcb4b8007d1079efc52;hb=f59eded7c3e162bbdfc6db424c9badc730017698;hp=0000000000000000000000000000000000000000;hpb=fab500d5bff644bb5637abd2f5e78baeb26b7f26;p=libs%2Fnet.git diff --git a/source/inet.h b/source/inet.h new file mode 100644 index 0000000..1092bc1 --- /dev/null +++ b/source/inet.h @@ -0,0 +1,50 @@ +/* $Id$ + +This file is part of libmspnet +Copyright © 2008 Mikkosoft Productions, Mikko Rasa +Distributed under the LGPL +*/ + +#ifndef MSP_NET_INET_H_ +#define MSP_NET_INET_H_ + +#ifdef WIN32 +#include +#else +#include +#endif +#include +#include "sockaddr.h" + +namespace Msp { +namespace Net { + +#ifdef WIN32 +typedef u_long in_addr_t; +typedef u_short in_port_t; +#endif + +/** +Address class for IPv4 sockets. +*/ +class InetAddr: public SockAddr +{ +public: + InetAddr(); + InetAddr(sockaddr_in &); + InetAddr(in_addr_t, in_port_t); + Family get_family() const { return INET; } + in_addr_t get_addr() const { return ntohl(addr); } + in_port_t get_port() const { return ntohs(port); } + std::string str() const; + unsigned fill_sockaddr(sockaddr &) const; + InetAddr *copy() const { return new InetAddr(*this); } +private: + in_addr_t addr; + in_port_t port; +}; + +} // namespace Net +} // namespace Msp + +#endif