summaryrefslogtreecommitdiff
path: root/chromium/net/socket/server_socket.cc
blob: 1cbfdfd28e1587ebcb67c25d2cb55ee2187461f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/socket/server_socket.h"

#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"

namespace net {

ServerSocket::ServerSocket() = default;

ServerSocket::~ServerSocket() = default;

int ServerSocket::ListenWithAddressAndPort(const std::string& address_string,
                                           uint16_t port,
                                           int backlog) {
  IPAddress ip_address;
  if (!ip_address.AssignFromIPLiteral(address_string)) {
    return ERR_ADDRESS_INVALID;
  }

  return Listen(IPEndPoint(ip_address, port), backlog);
}

int ServerSocket::Accept(std::unique_ptr<StreamSocket>* socket,
                         net::CompletionOnceCallback callback,
                         net::IPEndPoint* peer_address) {
  if (peer_address) {
    *peer_address = IPEndPoint();
  }
  return Accept(socket, std::move(callback));
}

}  // namespace net