Files
sdk/runtime/bin/socket.h
T
ager@google.com 1ffc9b84a2 Treat EAGAIN/EWOULDBLOCK as requests for retry on socket accept.
On Linux there are a number of protocol errors that can be
returned from accept. According to the linux man pages they
should be treated as EAGAIN.

This should hopefully fix the flakiness of EchoServerStreamTest.

R=iposva@google.com,sgjesse@google.com
BUG=2262
TEST=

Review URL: https://chromiumcodereview.appspot.com//9837060

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5797 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-23 22:39:27 +00:00

60 lines
1.6 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef BIN_SOCKET_H_
#define BIN_SOCKET_H_
#include "bin/builtin.h"
#include "bin/utils.h"
#include "platform/globals.h"
#include "platform/thread.h"
class Socket {
public:
enum SocketRequest {
kLookupRequest = 0,
};
static bool Initialize();
static intptr_t Available(intptr_t fd);
static int Read(intptr_t fd, void* buffer, intptr_t num_bytes);
static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes);
static intptr_t CreateConnect(const char* host, const intptr_t port);
static intptr_t GetPort(intptr_t fd);
static void GetError(intptr_t fd, OSError* os_error);
static intptr_t GetStdioHandle(int num);
// Perform a IPv4 hostname lookup. Returns the hostname string in
// IPv4 dotted-decimal format.
static const char* LookupIPv4Address(char* host, OSError** os_error);
static Dart_Port GetServicePort();
private:
static dart::Mutex mutex_;
static int service_ports_size_;
static Dart_Port* service_ports_;
static int service_ports_index_;
DISALLOW_ALLOCATION();
DISALLOW_IMPLICIT_CONSTRUCTORS(Socket);
};
class ServerSocket {
public:
static const intptr_t kTemporaryFailure = -2;
static intptr_t Accept(intptr_t fd);
static intptr_t CreateBindListen(const char* bindAddress,
intptr_t port,
intptr_t backlog);
DISALLOW_ALLOCATION();
DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket);
};
#endif // BIN_SOCKET_H_