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
This commit is contained in:
parent
83b5200f95
commit
2c13f659c7
@ -301,7 +301,8 @@ DataSocket* ListeningSocket::Accept() const {
|
||||
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;
|
||||
|
||||
|
@ -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 @@ class DataSocket : public SocketBase {
|
||||
OPTIONS,
|
||||
};
|
||||
|
||||
explicit DataSocket(int socket)
|
||||
explicit DataSocket(NativeSocket socket)
|
||||
: SocketBase(socket),
|
||||
method_(INVALID),
|
||||
content_length_(0) {
|
||||
|
Loading…
Reference in New Issue
Block a user