IPSocketAddress.st
changeset 4618 c68aee83ba0b
parent 4339 499b62578e95
child 4678 28f9a9f71751
equal deleted inserted replaced
4617:c3f514269170 4618:c68aee83ba0b
    84 allForHostName:name serviceName:portNrOrName type:socketTypeSymbol
    84 allForHostName:name serviceName:portNrOrName type:socketTypeSymbol
    85     "get a collection of new instance given a hostname, port or service and type.
    85     "get a collection of new instance given a hostname, port or service and type.
    86      Multi-homed hosts return more than one entry
    86      Multi-homed hosts return more than one entry
    87      Redefined to cache the result of the name-lookup.
    87      Redefined to cache the result of the name-lookup.
    88 
    88 
    89      Take care, this resolves to IPv4-adresses only!!
    89      Take care, this resolves to IPv4-addresses only!!
    90      Use SocketAddress to resolve to both IPv4 and IPv6-addresses."
    90      Use SocketAddress to resolve to both IPv4 and IPv6-addresses."
    91 
    91 
    92     |addressList|
    92     |addressList|
    93 
    93 
    94     portNrOrName isString ifTrue:[
    94     portNrOrName isString ifTrue:[
    95         ^ super allForHostName:name serviceName:portNrOrName type:socketTypeSymbol
    95         ^ super allForHostName:name serviceName:portNrOrName type:socketTypeSymbol
    96     ].
    96     ].
    97 
    97 
    98     addressList := self addressCacheAt:name.
    98     addressList := self addressCacheAt:name.
    99     addressList notNil ifTrue:[
    99     addressList notNil ifTrue:[
   100         addressList := addressList collect:[:eachSocketAddress| 
   100         addressList := addressList collect:[:eachSocketAddress|
   101                                 eachSocketAddress copy
   101                                 eachSocketAddress copy
   102                                     port:(portNrOrName ? 0);
   102                                     port:(portNrOrName ? 0);
   103                                     yourself
   103                                     yourself
   104                             ].
   104                             ].
   105     ] ifFalse:[
   105     ] ifFalse:[
   109         ].
   109         ].
   110     ].
   110     ].
   111     ^ addressList
   111     ^ addressList
   112 
   112 
   113     "
   113     "
   114      IPSocketAddress allForHostName:nil serviceName:10 type:#stream  
   114      IPSocketAddress allForHostName:nil serviceName:10 type:#stream
   115      SocketAddress allForHostName:'localhost' serviceName:10 type:#stream  
   115      SocketAddress allForHostName:'localhost' serviceName:10 type:#stream
   116      IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram 
   116      IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram
   117      IPSocketAddress allForHostName:'www.google.com' serviceName:80 type:nil      
   117      IPSocketAddress allForHostName:'www.google.com' serviceName:80 type:nil
   118      
   118 
   119      IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram 
   119      IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram
   120      IPv6SocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram 
   120      IPv6SocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram
   121     "
   121     "
   122 
   122 
   123     "Modified: / 17-06-2009 / 15:21:00 / sr"
   123     "Modified: / 17-06-2009 / 15:21:00 / sr"
   124     "Modified (comment): / 21-02-2017 / 20:59:52 / stefan"
   124     "Modified (comment): / 21-02-2017 / 20:59:52 / stefan"
   125 !
   125 !