@@ -51,36 +51,40 @@ class Socket < IO
51
51
52
52
# Creates a TCP socket. Consider using `TCPSocket` or `TCPServer` unless you
53
53
# need full control over the socket.
54
- #
55
- # NOTE: The *blocking* arg is deprecated since Crystal 1.17. Use `#blocking=`
56
- # to change the blocking mode after creating the socket.
57
- def self.tcp (family : Family , blocking = nil ) : self
54
+ def self.tcp (family : Family ) : self
55
+ new(family, Type ::STREAM , Protocol ::TCP )
56
+ end
57
+
58
+ @[Deprecated (" The blocking argument is deprecated. Use #blocking= to change it after creating the socket." )]
59
+ def self.tcp (family : Family , blocking) : self
58
60
new(family, Type ::STREAM , Protocol ::TCP , blocking)
59
61
end
60
62
61
63
# Creates an UDP socket. Consider using `UDPSocket` unless you need full
62
64
# control over the socket.
63
- #
64
- # NOTE: The *blocking* arg is deprecated since Crystal 1.17. Use `#blocking=`
65
- # to change the blocking mode after creating the socket.
66
- def self.udp (family : Family , blocking = nil ) : self
65
+ def self.udp (family : Family ) : self
66
+ new(family, Type ::DGRAM , Protocol ::UDP )
67
+ end
68
+
69
+ @[Deprecated (" The blocking argument is deprecated. Use #blocking= to change it after creating the socket." )]
70
+ def self.udp (family : Family , blocking) : self
67
71
new(family, Type ::DGRAM , Protocol ::UDP , blocking)
68
72
end
69
73
70
74
# Creates an UNIX socket. Consider using `UNIXSocket` or `UNIXServer` unless
71
75
# you need full control over the socket.
72
76
#
73
- # NOTE: The *blocking* arg is deprecated since Crystal 1.17. Use `#blocking=`
74
- # to change the blocking mode after creating the socket.
77
+ # NOTE: The *blocking* argument is deprecated. Use `#blocking=` to change it
78
+ # after creating the socket.
75
79
def self.unix (type : Type = Type ::STREAM , blocking = nil ) : self
76
80
new(Family ::UNIX , type , blocking: blocking)
77
81
end
78
82
79
83
# Creates a socket. Consider using `TCPSocket`, `TCPServer`, `UDPSocket`,
80
84
# `UNIXSocket` or `UNIXServer` unless you need full control over the socket.
81
85
#
82
- # NOTE: The *blocking* arg is deprecated since Crystal 1.17. Use `#blocking=`
83
- # to change the blocking mode after creating the socket.
86
+ # NOTE: The *blocking* argument is deprecated since Crystal 1.17. Use
87
+ # `#blocking=` to change it after creating the socket.
84
88
def initialize (family : Family , type : Type , protocol : Protocol = Protocol ::IP , blocking = nil )
85
89
# This method is `#initialize` instead of `.new` because it is used as super
86
90
# constructor from subclasses.
@@ -95,8 +99,8 @@ class Socket < IO
95
99
# event loop runtime requirements.
96
100
#
97
101
# NOTE: On Windows the handle must have been created with `WSA_FLAG_OVERLAPPED`.
98
- # NOTE: The *blocking* arg is deprecated since Crystal 1.17. Use `#blocking=`
99
- # to change the blocking mode after creating the socket.
102
+ # NOTE: The *blocking* argument is deprecated since Crystal 1.17. Use
103
+ # `#blocking=` to change it after creating the socket.
100
104
def initialize (fd, @family : Family , @type : Type , @protocol : Protocol = Protocol ::IP , blocking = nil )
101
105
initialize(handle: fd, family: family, type: type , protocol: protocol)
102
106
blocking = Crystal ::EventLoop .default_socket_blocking? if blocking.nil?
0 commit comments