Add a platform specific typedef for SOCKET in the peerconnection_server example since it's not universally 'int'.
R=pbos@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/33439004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7763 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/examples/peerconnection/server/data_socket.cc b/talk/examples/peerconnection/server/data_socket.cc
index 37e7cd5..7495025 100644
--- a/talk/examples/peerconnection/server/data_socket.cc
+++ b/talk/examples/peerconnection/server/data_socket.cc
@@ -301,7 +301,8 @@
assert(valid());
struct sockaddr_in addr = {0};
socklen_t size = sizeof(addr);
- int client = accept(socket_, reinterpret_cast<sockaddr*>(&addr), &size);
+ NativeSocket client =
+ accept(socket_, reinterpret_cast<sockaddr*>(&addr), &size);
if (client == INVALID_SOCKET)
return NULL;
diff --git a/talk/examples/peerconnection/server/data_socket.h b/talk/examples/peerconnection/server/data_socket.h
index b2ba28d..fe4f2fc 100644
--- a/talk/examples/peerconnection/server/data_socket.h
+++ b/talk/examples/peerconnection/server/data_socket.h
@@ -32,37 +32,39 @@
#ifdef WIN32
#include <winsock2.h>
typedef int socklen_t;
+typedef SOCKET NativeSocket;
#else
#include <netinet/in.h>
#include <sys/select.h>
#include <sys/socket.h>
#define closesocket close
-#endif
-
-#include <string>
+typedef int NativeSocket;
#ifndef SOCKET_ERROR
#define SOCKET_ERROR (-1)
#endif
#ifndef INVALID_SOCKET
-#define INVALID_SOCKET static_cast<int>(~0)
+#define INVALID_SOCKET static_cast<NativeSocket>(-1)
#endif
+#endif
+
+#include <string>
class SocketBase {
public:
SocketBase() : socket_(INVALID_SOCKET) { }
- explicit SocketBase(int socket) : socket_(socket) { }
+ explicit SocketBase(NativeSocket socket) : socket_(socket) { }
~SocketBase() { Close(); }
- int socket() const { return socket_; }
+ NativeSocket socket() const { return socket_; }
bool valid() const { return socket_ != INVALID_SOCKET; }
bool Create();
void Close();
protected:
- int socket_;
+ NativeSocket socket_;
};
// Represents an HTTP server socket.
@@ -75,7 +77,7 @@
OPTIONS,
};
- explicit DataSocket(int socket)
+ explicit DataSocket(NativeSocket socket)
: SocketBase(socket),
method_(INVALID),
content_length_(0) {