mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
TCPSocket.new supports "local_host" and "local_service".
This commit is contained in:
@@ -236,6 +236,12 @@ class TCPSocket
|
||||
Addrinfo.foreach(host, service) { |ai|
|
||||
begin
|
||||
s = Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0)
|
||||
if local_host or local_service
|
||||
local_host ||= (ai.afamily == Socket::AF_INET) ? "0.0.0.0" : "::"
|
||||
local_service ||= "0"
|
||||
bi = Addrinfo.getaddrinfo(local_host, local_service, ai.afamily, ai.socktype)[0]
|
||||
Socket._bind(s, bi.to_sockaddr)
|
||||
end
|
||||
Socket._connect(s, ai.to_sockaddr)
|
||||
super(s, "r+")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user