| Index: src/platform.h
|
| ===================================================================
|
| --- src/platform.h (revision 1344)
|
| +++ src/platform.h (working copy)
|
| @@ -109,6 +109,9 @@
|
|
|
| double ceiling(double x);
|
|
|
| +// Forward declarations.
|
| +class Socket;
|
| +
|
| // ----------------------------------------------------------------------------
|
| // OS
|
| //
|
| @@ -205,6 +208,10 @@
|
| // Please use delete to reclaim the storage for the returned Semaphore.
|
| static Semaphore* CreateSemaphore(int count);
|
|
|
| + // Factory method for creating platform dependent Socket.
|
| + // Please use delete to reclaim the storage for the returned Socket.
|
| + static Socket* CreateSocket();
|
| +
|
| class MemoryMappedFile {
|
| public:
|
| static MemoryMappedFile* create(const char* name, int size, void* initial);
|
| @@ -412,6 +419,38 @@
|
| };
|
|
|
|
|
| +// ----------------------------------------------------------------------------
|
| +// Socket
|
| +//
|
| +
|
| +class Socket {
|
| + public:
|
| + virtual ~Socket() {}
|
| +
|
| + // Server initialization.
|
| + virtual bool Bind (const int port) = 0;
|
| + virtual bool Listen(int backlog) const = 0;
|
| + virtual Socket* Accept() const = 0;
|
| +
|
| + // Client initialization.
|
| + virtual bool Connect(const char* host, const char* port) = 0;
|
| +
|
| + // Data Transimission
|
| + virtual int Send(const char* data, int len) const = 0;
|
| + virtual bool SendAll(const char* data, int len) const = 0;
|
| + virtual int Receive(char* data, int len) const = 0;
|
| +
|
| + virtual bool IsValid() const = 0;
|
| +
|
| + static bool Setup();
|
| + static int LastError();
|
| + static uint16_t HToN(uint16_t value);
|
| + static uint16_t NToH(uint16_t value);
|
| + static uint32_t HToN(uint32_t value);
|
| + static uint32_t NToH(uint32_t value);
|
| +};
|
| +
|
| +
|
| #ifdef ENABLE_LOGGING_AND_PROFILING
|
| // ----------------------------------------------------------------------------
|
| // Sampler
|
|
|