-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathOption.swift
41 lines (35 loc) · 1.47 KB
/
Option.swift
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
38
39
40
41
//
// Option.swift
// SocketSwift
//
// Created by Orkhan Alikhanov on 7/7/17.
// Copyright © 2017 BiAtoms. All rights reserved.
//
import Foundation //Darwin or Glibc
extension Socket {
public class BaseOption: RawRepresentable {
public let rawValue: Int32
public required init(rawValue: Int32) {
self.rawValue = rawValue
}
}
public class Option<T>: BaseOption {}
}
extension Socket.BaseOption {
private typealias Option = Socket.Option
public static let reuseAddress = Option<Bool>(rawValue: SO_REUSEADDR)
public static let reusePort = Option<Bool>(rawValue: SO_REUSEPORT)
public static let keepAlive = Option<Bool>(rawValue: SO_KEEPALIVE)
public static let debug = Option<Bool>(rawValue: SO_DEBUG)
public static let dontRoute = Option<Bool>(rawValue: SO_DONTROUTE)
public static let broadcast = Option<Bool>(rawValue: SO_BROADCAST)
public static let sendBufferSize = Option<Int32>(rawValue: SO_SNDBUF)
public static let receiveBufferSize = Option<Int32>(rawValue: SO_RCVBUF)
public static let sendLowWaterMark = Option<Int32>(rawValue: SO_SNDLOWAT)
public static let receiveLowWaterMark = Option<Int32>(rawValue: SO_RCVLOWAT)
public static let sendTimeout = Option<TimeValue>(rawValue: SO_SNDTIMEO)
public static let receiveTimeout = Option<TimeValue>(rawValue: SO_RCVTIMEO)
#if !os(Linux)
public static let noSignalPipe = Option<Bool>(rawValue: SO_NOSIGPIPE)
#endif
}