Added the sf::Time class

This commit is contained in:
Laurent Gomila 2012-01-19 23:51:06 +01:00
parent e775bd0169
commit 4116ad033c
58 changed files with 880 additions and 227 deletions

View file

@ -106,7 +106,7 @@ unsigned short TcpSocket::GetRemotePort() const
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short remotePort, Uint32 timeout)
Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout)
{
// Create the internal socket if it doesn't exist
Create();
@ -114,7 +114,7 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short
// Create the remote address
sockaddr_in address = priv::SocketImpl::CreateAddress(remoteAddress.ToInteger(), remotePort);
if (timeout == 0)
if (timeout <= Time::Zero)
{
// ----- We're not using a timeout: just try to connect -----
@ -160,8 +160,8 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short
// Setup the timeout
timeval time;
time.tv_sec = timeout / 1000;
time.tv_usec = (timeout - time.tv_sec * 1000) * 1000;
time.tv_sec = static_cast<long>(timeout.AsMicroseconds() / 1000000);
time.tv_usec = static_cast<long>(timeout.AsMicroseconds() % 1000000);
// Wait for something to write on our socket (which means that the connection request has returned)
if (select(static_cast<int>(GetHandle() + 1), NULL, &selector, NULL, &time) > 0)