1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "base/sync_socket.h" 6 7#include <errno.h> 8#include <limits.h> 9#include <stdio.h> 10#include <sys/types.h> 11 12#include "base/logging.h" 13 14 15namespace base { 16 17const SyncSocket::Handle SyncSocket::kInvalidHandle = -1; 18 19SyncSocket::SyncSocket() : handle_(kInvalidHandle) { 20} 21 22SyncSocket::~SyncSocket() { 23} 24 25// static 26bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) { 27 return false; 28} 29 30bool SyncSocket::Close() { 31 if (handle_ != kInvalidHandle) { 32 if (close(handle_) < 0) 33 DPLOG(ERROR) << "close"; 34 handle_ = -1; 35 } 36 return true; 37} 38 39size_t SyncSocket::Send(const void* buffer, size_t length) { 40 // Not implemented since it's not needed by any client code yet. 41 return -1; 42} 43 44size_t SyncSocket::Receive(void* buffer, size_t length) { 45 return read(handle_, buffer, length); 46} 47 48size_t SyncSocket::Peek() { 49 return -1; 50} 51 52CancelableSyncSocket::CancelableSyncSocket() { 53} 54 55CancelableSyncSocket::CancelableSyncSocket(Handle handle) 56 : SyncSocket(handle) { 57} 58 59size_t CancelableSyncSocket::Send(const void* buffer, size_t length) { 60 return -1; 61} 62 63bool CancelableSyncSocket::Shutdown() { 64 return false; 65} 66 67// static 68bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, 69 CancelableSyncSocket* socket_b) { 70 return SyncSocket::CreatePair(socket_a, socket_b); 71} 72 73} // namespace base 74