1234567891011121314151617181920212223242526 |
- // Copyright (c) 2016 Arista Networks, Inc.
- // Use of this source code is governed by the Apache License 2.0
- // that can be found in the COPYING file.
- // Package dscp provides helper functions to apply DSCP / ECN / CoS flags to sockets.
- package dscp
- import (
- "net"
- )
- // ListenTCPWithTOS is similar to net.ListenTCP but with the socket configured
- // to the use the given ToS (Type of Service), to specify DSCP / ECN / class
- // of service flags to use for incoming connections.
- func ListenTCPWithTOS(address *net.TCPAddr, tos byte) (*net.TCPListener, error) {
- lsnr, err := net.ListenTCP("tcp", address)
- if err != nil {
- return nil, err
- }
- if err = setTOS(address.IP, lsnr, tos); err != nil {
- lsnr.Close()
- return nil, err
- }
- return lsnr, err
- }
|