• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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"""Open a socket without listening.
6
7This is used for testing leasing.
8"""
9
10from __future__ import absolute_import
11from __future__ import division
12from __future__ import print_function
13
14import logging
15import socket
16import sys
17import time
18
19from lucifer import loglib
20
21logger = logging.getLogger(__name__)
22
23
24def main(_args):
25    """Main function
26
27    @param args: list of command line args
28    """
29    loglib.configure_logging(name='abort_socket')
30    sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
31    sock.bind(sys.argv[1])
32    # Minimum value is 256 on Linux (but on my machine it's 2304).
33    # See also socket(7).
34    sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 128)
35    print('done')
36    while True:
37        time.sleep(10)
38
39
40
41if __name__ == '__main__':
42    sys.exit(main(sys.argv[1:]))
43