Added (sock_t) to quiet compiler warnings in MinGW

pull/1/head
Ross Smith II 2009-06-02 03:18:07 +00:00
parent 3455fca9ca
commit 2e34ea1e42
2 changed files with 14 additions and 14 deletions

View File

@ -178,7 +178,7 @@ void SocketCore::bind(uint16_t port)
struct addrinfo* rp;
for(rp = res; rp; rp = rp->ai_next) {
sock_t fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(fd == -1) {
if(fd == (sock_t) -1) {
continue;
}
int sockopt = 1;
@ -194,7 +194,7 @@ void SocketCore::bind(uint16_t port)
break;
}
freeaddrinfo(res);
if(sockfd == -1) {
if(sockfd == (sock_t) -1) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_BIND, "all addresses failed").str());
}
}
@ -211,8 +211,8 @@ SocketCore* SocketCore::acceptConnection() const
struct sockaddr_storage sockaddr;
socklen_t len = sizeof(sockaddr);
sock_t fd;
while((fd = accept(sockfd, reinterpret_cast<struct sockaddr*>(&sockaddr), &len)) == -1 && SOCKET_ERRNO == EINTR);
if(fd == -1) {
while((fd = accept(sockfd, reinterpret_cast<struct sockaddr*>(&sockaddr), &len)) == (sock_t) -1 && SOCKET_ERRNO == EINTR);
if(fd == (sock_t) -1) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_ACCEPT, errorMsg()).str());
}
return new SocketCore(fd, _sockType);
@ -260,7 +260,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
struct addrinfo* rp;
for(rp = res; rp; rp = rp->ai_next) {
sock_t fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(fd == -1) {
if(fd == (sock_t) -1) {
continue;
}
int sockopt = 1;
@ -274,7 +274,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
if(connect(fd, rp->ai_addr, rp->ai_addrlen) == -1 &&
SOCKET_ERRNO != A2_EINPROGRESS) {
CLOSE(sockfd);
sockfd = -1;
sockfd = (sock_t) -1;
continue;
}
// TODO at this point, connection may not be established and it may fail
@ -282,7 +282,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
break;
}
freeaddrinfo(res);
if(sockfd == -1) {
if(sockfd == (sock_t) -1) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_CONNECT, host.c_str(),
"all addresses failed").str());
}
@ -333,7 +333,7 @@ void SocketCore::closeConnection()
gnutls_bye(sslSession, GNUTLS_SHUT_RDWR);
}
#endif // HAVE_LIBGNUTLS
if(sockfd != -1) {
if(sockfd != (sock_t) -1) {
CLOSE(sockfd);
sockfd = -1;
}

View File

@ -141,7 +141,7 @@ public:
sock_t getSockfd() const { return sockfd; }
bool isOpen() const { return sockfd != -1; }
bool isOpen() const { return sockfd != (sock_t) -1; }
/**
* Creates a socket and bind it with locahost's address and port.