Home | History | Annotate | Download | only in test
      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 
      7 This is used for testing leasing.
      8 """
      9 
     10 from __future__ import absolute_import
     11 from __future__ import division
     12 from __future__ import print_function
     13 
     14 import logging
     15 import socket
     16 import sys
     17 import time
     18 
     19 from lucifer import loglib
     20 
     21 logger = logging.getLogger(__name__)
     22 
     23 
     24 def 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 
     41 if __name__ == '__main__':
     42     sys.exit(main(sys.argv[1:]))
     43