aboutsummaryrefslogtreecommitdiffstats
path: root/vbench/src/vbench/test/server_socket.h
blob: af3a3365309e4d9632b405372ae12223b737e26e (plain) (blame)
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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.


#pragma once

#include <vbench/core/stream.h>

namespace vbench {

/**
 * Simple server socket listening to a random port.
 **/
class ServerSocket
{
private:
    FastOS_ServerSocket _serverSocket;
    volatile bool _closed;

public:
    ServerSocket();
    Stream::UP accept();
    int port() { return _serverSocket.GetLocalPort(); }
    void close() { _closed = true; }
};

} // namespace vbench