28#include <SFML/Network/IPAddress.hpp>
29#include <SFML/Network/Http.hpp>
30#include <SFML/Network/SocketHelper.hpp>
58 myAddress = inet_addr(Address.c_str());
63 hostent* Host = gethostbyname(Address.c_str());
67 myAddress =
reinterpret_cast<in_addr*
>(Host->h_addr)->s_addr;
72 myAddress = INADDR_NONE;
85 myAddress = inet_addr(Address);
90 hostent* Host = gethostbyname(Address);
94 myAddress =
reinterpret_cast<in_addr*
>(Host->h_addr)->s_addr;
99 myAddress = INADDR_NONE;
110 myAddress = htonl((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
119 myAddress = htonl(Address);
128 return myAddress != INADDR_NONE;
138 InAddr.s_addr = myAddress;
140 return inet_ntoa(InAddr);
149 return ntohl(myAddress);
165 SocketHelper::SocketType Socket = socket(PF_INET, SOCK_DGRAM, 0);
170 sockaddr_in SockAddr;
171 memset(SockAddr.sin_zero, 0,
sizeof(SockAddr.sin_zero));
172 SockAddr.sin_addr.s_addr = INADDR_LOOPBACK;
173 SockAddr.sin_family = AF_INET;
174 SockAddr.sin_port = htons(4567);
177 if (connect(Socket,
reinterpret_cast<sockaddr*
>(&SockAddr),
sizeof(SockAddr)) == -1)
184 SocketHelper::LengthType Size =
sizeof(SockAddr);
185 if (getsockname(Socket,
reinterpret_cast<sockaddr*
>(&SockAddr), &Size) == -1)
195 LocalAddress.myAddress = SockAddr.sin_addr.s_addr;
212 Http Server(
"www.sfml-dev.org");
228 return myAddress == Other.myAddress;
237 return myAddress != Other.myAddress;
246 return myAddress < Other.myAddress;
255 return myAddress > Other.myAddress;
264 return myAddress <= Other.myAddress;
273 return myAddress >= Other.myAddress;
280std::istream& operator >>(std::istream& Stream,
IPAddress& Address)
293std::ostream& operator <<(std::ostream& Stream,
const IPAddress& Address)
295 return Stream << Address.ToString();
This class wraps an HTTP request, which is basically :
@ Get
Request in get mode, standard method to retrieve a page.
This class wraps an HTTP response, which is basically :
Status GetStatus() const
Get the header's status code.
@ Ok
Most common code returned when operation was successful.
const std::string & GetBody() const
Get the body of the response.
This class provides methods for manipulating the HTTP protocol (described in RFC 1945).
Response SendRequest(const Request &Req, float Timeout=0.f)
Send a HTTP request and return the server's response.
IPAddress provides easy manipulation of IP v4 addresses.
bool operator>=(const IPAddress &Other) const
Comparison operator >=.
bool operator!=(const IPAddress &Other) const
Comparison operator !=.
static const IPAddress LocalHost
Local host address (to connect to the same computer).
bool operator>(const IPAddress &Other) const
Comparison operator >.
Uint32 ToInteger() const
Get an integer representation of the address.
bool operator<(const IPAddress &Other) const
Comparison operator <.
static IPAddress GetLocalAddress()
Get the computer's local IP address (from the LAN point of view).
static IPAddress GetPublicAddress(float Timeout=0.f)
Get the computer's public IP address (from the web point of view).
IPAddress()
Default constructor – constructs an invalid address.
bool operator<=(const IPAddress &Other) const
Comparison operator <=.
bool operator==(const IPAddress &Other) const
Comparison operator ==.
std::string ToString() const
Get a string representation of the address.
bool IsValid() const
Tell if the address is a valid one.
static SocketType InvalidSocket()
Return the value of the invalid socket.
static bool Close(SocketType Socket)
Close / destroy a socket.