SocketAddress.st
author penk
Fri, 17 Oct 2003 18:43:03 +0200
changeset 1333 d9ebcc42524c
parent 1281 6df4f8f211e3
child 1366 e01d0f6c102a
permissions -rw-r--r--
printing refactored
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    13
"{ Package: 'stx:libbasic2' }"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    14
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
    15
UninterpretedBytes variableByteSubclass:#SocketAddress
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    16
	instanceVariableNames:''
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    17
	classVariableNames:'DomainToClassMapping'
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    18
	poolDictionaries:''
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    19
	category:'OS-Sockets'
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    22
!SocketAddress primitiveDefinitions!
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    23
%{
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    24
#include "stxOSDefs.h"
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    25
%}
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    26
! !
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    27
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!SocketAddress class methodsFor:'documentation'!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
copyright
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 COPYRIGHT (c) 1995 by Claus Gittinger
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	      All Rights Reserved
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 This software is furnished under a license and may be used
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 only in accordance with the terms of that license and with the
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 inclusion of the above copyright notice.   This software may not
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 be provided or otherwise made available to, or used by, any
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 other person.  No title to or ownership of the software is
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 hereby transferred.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
documentation
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
    46
    Abstract superclass for subclasses implementing various IPC addressing schemes.
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
    47
    See concrete examples IPSocketAddress and UDSocketAddress.
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
    48
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    ST-80 compatibility class.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    This may be required when existing code has to be ported to ST/X;
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    however, it may not be complete and more protocol may be added in the future.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    The code here was created when public domain code (Manchester) had to
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    be ported to ST/X and missing classes/methods were encountered, and code added
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    by reasoning 'what the original class could probably do there'.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    This is an additional goody class; therefore:
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    SUCH DAMAGE.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
! !
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    72
!SocketAddress class methodsFor:'instance creation'!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    73
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
    74
anyHost
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
    75
    "get a new instance representing the ANY-host address"
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
    76
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
    77
    ^ self hostAddress:(self anyAddress) port:0
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
    78
!
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
    79
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    80
hostAddress:addr
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    81
    "get a new instance given addr-bytes"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    82
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    83
    ^ self hostAddress:addr port:0
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    84
!
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    85
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    86
hostAddress:addr port:portNr
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    87
    "get a new instance given addr-bytes and a portNr"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    88
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    89
    ^ self new hostAddress:addr; port:portNr
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    90
!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    91
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    92
hostName:name
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    93
    "get a new instance given a hostname"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    94
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    95
    ^ self hostName:name serviceName:nil type:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    96
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    97
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    98
hostName:name port:portNr
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    99
    "get a new instance given a hostname and port"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   100
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   101
    ^ self hostName:name serviceName:portNr type:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   102
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   103
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   104
hostName:name serviceName:portNrOrName type:socketTypeSymbol
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   105
    "get a new instance given a hostname, port or service and type"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   106
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   107
    |addressInfo serviceName port sa|
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   108
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   109
    portNrOrName isString ifTrue:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   110
        serviceName := portNrOrName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   111
    ] ifFalse:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   112
        port := portNrOrName.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   113
    ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   114
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   115
    addressInfo := self 
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   116
                    getAddressInfo:name 
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   117
                    serviceName:serviceName 
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   118
                    domain:(self domainSymbol) 
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   119
                    type:socketTypeSymbol
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   120
                    protocol:nil 
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   121
                    flags:0.
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   122
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   123
    sa := addressInfo first socketAddress.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   124
    addressInfo size > 1 ifTrue:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   125
        (addressInfo contains:[:entry| entry socketAddress ~= sa]) ifTrue:[
1232
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   126
            'SocketAddress [warning]: multiple hostAddresses for host' infoPrintCR.
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   127
        ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   128
    ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   129
    port notNil ifTrue:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   130
        sa port:port.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   131
    ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   132
    ^ sa
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   133
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   134
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   135
     SocketAddress hostName:'localhost' serviceName:10 type:#stream
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   136
     IPSocketAddress hostName:'localhost' serviceName:'echo' type:#datagram 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   137
     IPSocketAddress hostName:'localhost' serviceName:'echo' type:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   138
    "
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   139
!
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   140
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   141
new
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   142
    |numBytes|
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   143
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   144
    self == SocketAddress ifTrue:[
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   145
        self error:'SocketAddress is abstract'.
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   146
    ].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   147
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   148
    numBytes := self socketAddressSize.
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   149
    numBytes isNil ifTrue:[
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   150
        self error:'unsupported domain'.
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   151
        ^ nil
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   152
    ].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   153
    ^ (self new:numBytes) domainCode:(self domainCode)
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   154
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   155
    "
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   156
     IPSocketAddress new            
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   157
     IPv6SocketAddress new          
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   158
     UDSocketAddress new            
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   159
     AppletalkSocketAddress new
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   160
   "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   161
!
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   162
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   163
newDomain:domain
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   164
   "answer an new socket address for a given domain"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   165
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   166
   ^ (self knownClassFromCode:domain) new
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   167
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   168
   "
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   169
    self newDomain:#afUnix    
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   170
    self newDomain:#afInet    
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   171
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   172
    self newDomain:#'AF_UNIX' 
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   173
    self newDomain:#'AF_INET' 
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   174
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   175
    self newDomain:#unix
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   176
    self newDomain:#inet
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   177
   "
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   178
! !
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   179
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   180
!SocketAddress class methodsFor:'addressing'!
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   181
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   182
anyAddress
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   183
    self subclassResponsibility
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   184
! !
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   185
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
!SocketAddress class methodsFor:'queries'!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   188
domainCode
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   189
    "answer the numerical domain code used in socket addresses"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   190
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   191
    ^ OperatingSystem domainCodeOf:(self domainSymbol)
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   192
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   193
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
domainCodeFromName:aNameSymbol
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   195
    "this is a compatibility method;
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   196
     VW returns the internal unix codes here - however, in ST/X,
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   197
     symbols are returned, which are translated later"
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   198
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   199
    aNameSymbol isInteger ifTrue:[ ^ aNameSymbol ].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   200
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   201
    "here, all possible variants are translated to AF_* symbols,
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   202
     which are handled by the primitives"
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   203
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   204
    aNameSymbol == #afUnix      ifTrue:[^ #'AF_UNIX'].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   205
    aNameSymbol == #AF_UNIX     ifTrue:[^ #'AF_UNIX'].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   206
    aNameSymbol == #unix        ifTrue:[^ #'AF_UNIX'].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   207
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   208
    aNameSymbol == #afInet      ifTrue:[^ #'AF_INET'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   209
    aNameSymbol == #'AF_INET'   ifTrue:[^ #'AF_INET'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   210
    aNameSymbol == #inet        ifTrue:[^ #'AF_INET'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   211
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   212
    aNameSymbol == #afIpV6      ifTrue:[^ #'AF_INET6'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   213
    aNameSymbol == #'AF_INET6'  ifTrue:[^ #'AF_INET6'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   214
    aNameSymbol == #inet6       ifTrue:[^ #'AF_INET6'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   215
    aNameSymbol == #afInet6     ifTrue:[^ #'AF_INET6'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   216
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   217
    aNameSymbol == #afAppletalk    ifTrue:[^ #'AF_APPLETALK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   218
    aNameSymbol == #'AF_APPLETALK' ifTrue:[^ #'AF_APPLETALK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   219
    aNameSymbol == #appletalk      ifTrue:[^ #'AF_APPLETALK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   220
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   221
    aNameSymbol == #afDecnet    ifTrue:[^ #'AF_DECnet'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   222
    aNameSymbol == #'AF_DECnet' ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   223
    aNameSymbol == #'AF_DECNET' ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   224
    aNameSymbol == #decnet      ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   225
    aNameSymbol == #decNet      ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   226
    aNameSymbol == #DECnet      ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   227
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   228
    aNameSymbol == #afSna       ifTrue:[^ #'AF_SNA'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   229
    aNameSymbol == #'AF_SNA'    ifTrue:[^ #'AF_SNA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   230
    aNameSymbol == #sna         ifTrue:[^ #'AF_SNA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   231
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   232
    aNameSymbol == #afNs        ifTrue:[^ #'AF_NS'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   233
    aNameSymbol == #'AF_NS'     ifTrue:[^ #'AF_NS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   234
    aNameSymbol == #ns          ifTrue:[^ #'AF_NS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   235
    aNameSymbol == #xns         ifTrue:[^ #'AF_NS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   236
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   237
    aNameSymbol == #afCcitt     ifTrue:[^ #'AF_CCITT'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   238
    aNameSymbol == #'AF_CCITT'  ifTrue:[^ #'AF_CCITT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   239
    aNameSymbol == #ccitt       ifTrue:[^ #'AF_CCITT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   240
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   241
    aNameSymbol == #afImplink    ifTrue:[^ #'AF_IMPLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   242
    aNameSymbol == #'AF_IMPLINK' ifTrue:[^ #'AF_IMPLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   243
    aNameSymbol == #implink      ifTrue:[^ #'AF_IMPLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   244
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   245
    aNameSymbol == #afPup       ifTrue:[^ #'AF_PUP'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   246
    aNameSymbol == #'AF_PUP'    ifTrue:[^ #'AF_PUP'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   247
    aNameSymbol == #pup         ifTrue:[^ #'AF_PUP'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   248
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   249
    aNameSymbol == #afChaos    ifTrue:[^ #'AF_CHAOS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   250
    aNameSymbol == #'AF_CHAOS' ifTrue:[^ #'AF_CHAOS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   251
    aNameSymbol == #chaos      ifTrue:[^ #'AF_CHAOS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   252
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   253
    aNameSymbol == #afEcma      ifTrue:[^ #'AF_ECMA'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   254
    aNameSymbol == #'AF_ECMA'   ifTrue:[^ #'AF_ECMA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   255
    aNameSymbol == #ecma        ifTrue:[^ #'AF_ECMA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   256
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   257
    aNameSymbol == #afDatakit    ifTrue:[^ #'AF_DATAKIT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   258
    aNameSymbol == #'AF_DATAKIT' ifTrue:[^ #'AF_DATAKIT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   259
    aNameSymbol == #datakit      ifTrue:[^ #'AF_DATAKIT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   260
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   261
    aNameSymbol == #afDli     ifTrue:[^ #'AF_DLI'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   262
    aNameSymbol == #'AF_DLI'  ifTrue:[^ #'AF_DLI'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   263
    aNameSymbol == #dli       ifTrue:[^ #'AF_DLI'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   264
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   265
    aNameSymbol == #afLat     ifTrue:[^ #'AF_LAT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   266
    aNameSymbol == #'AF_LAT'  ifTrue:[^ #'AF_LAT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   267
    aNameSymbol == #lat       ifTrue:[^ #'AF_LAT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   268
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   269
    aNameSymbol == #afHylink    ifTrue:[^ #'AF_HYLINK'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   270
    aNameSymbol == #'AF_HYLINK' ifTrue:[^ #'AF_HYLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   271
    aNameSymbol == #hylink      ifTrue:[^ #'AF_HYLINK'].    
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   272
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   273
    aNameSymbol == #afUnspec    ifTrue:[^ #'AF_UNSPEC'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   274
    aNameSymbol == #'AF_UNSPEC' ifTrue:[^ #'AF_UNSPEC'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   275
    aNameSymbol == #unspec      ifTrue:[^ #'AF_UNSPEC'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   276
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   277
    aNameSymbol == #afRaw    ifTrue:[^ #'AF_RAW'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   278
    aNameSymbol == #'AF_RAW' ifTrue:[^ #'AF_RAW'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   279
    aNameSymbol == #raw      ifTrue:[^ #'AF_RAW'].    
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   280
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    "/
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    "/ could someone tell me which symbols are used in ST-80's SocketAddress class ?
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "/
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    self error:'no more mimicri implemented yet ...'
602
b7afbf8a1589 Support #afInet.
Stefan Vogel <sv@exept.de>
parents: 488
diff changeset
   285
b7afbf8a1589 Support #afInet.
Stefan Vogel <sv@exept.de>
parents: 488
diff changeset
   286
    "Modified: / 9.1.1998 / 10:03:56 / stefan"
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   287
!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   288
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   289
domainNameFromCode:code
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   290
    "this is a compatibility method;
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   291
     VW expects the internal unix codes here - however, in ST/X,
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   292
     symbols are expected - keeping the numeric values secret (in Socket)"
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   293
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   294
    code == #unix           ifTrue:[^ #afUnix].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   295
    code == #'AF_UNIX'      ifTrue:[^ #afUnix].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   296
    code == #'afUnix'       ifTrue:[^ #afUnix].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   297
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   298
    code == #inet           ifTrue:[^ #afInet].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   299
    code == #'AF_INET'      ifTrue:[^ #afInet].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   300
    code == #'afInet'       ifTrue:[^ #afInet].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   301
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   302
    code == #inet6          ifTrue:[^ #afIpV6].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   303
    code == #'AF_INET6'     ifTrue:[^ #afIpV6].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   304
    code == #'afIpV6'       ifTrue:[^ #afIpV6].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   305
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   306
    code == #appletalk      ifTrue:[^ #afAppletalk].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   307
    code == #'AF_APPLETALK' ifTrue:[^ #afAppletalk].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   308
    code == #'afAppletalk'  ifTrue:[^ #afAppletalk].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   309
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   310
    code == #decnet         ifTrue:[^ #afDecnet].
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   311
    code == #DECnet         ifTrue:[^ #afDecnet].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   312
    code == #decNet         ifTrue:[^ #afDecnet].
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   313
    code == #'AF_DECNET'    ifTrue:[^ #afDecnet].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   314
    code == #'AF_DECnet'    ifTrue:[^ #afDecnet].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   315
    code == #'afDecnet'     ifTrue:[^ #afDecnet].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   316
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   317
    code == #sna            ifTrue:[^ #afSna].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   318
    code == #'AF_SNA'       ifTrue:[^ #afSna].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   319
    code == #'afSna'        ifTrue:[^ #afSna].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   320
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   321
    code == #xns            ifTrue:[^ #afNs].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   322
    code == #ns             ifTrue:[^ #afNs].
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   323
    code == #'AF_NS'        ifTrue:[^ #afNs].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   324
    code == #'afNs'         ifTrue:[^ #afNs].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   325
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   326
    code == #ccitt          ifTrue:[^ #afCcitt].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   327
    code == #'AF_CCITT'     ifTrue:[^ #afCcitt].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   328
    code == #'afCcitt'      ifTrue:[^ #afCcitt].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   329
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   330
    code == #implink      ifTrue:[^ #afImplink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   331
    code == #'AF_IMPLINK' ifTrue:[^ #afImplink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   332
    code == #afImplink    ifTrue:[^ #afImplink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   333
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   334
    code == #pup         ifTrue:[^ #afPup].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   335
    code == #'AF_PUP'    ifTrue:[^ #afPup].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   336
    code == #afPup       ifTrue:[^ #afPup].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   337
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   338
    code == #chaos      ifTrue:[^ #afChaos].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   339
    code == #'AF_CHAOS' ifTrue:[^ #afChaos].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   340
    code == #afChaos    ifTrue:[^ #afChaos].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   341
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   342
    code == #ecma        ifTrue:[^ #afEcma].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   343
    code == #'AF_ECMA'   ifTrue:[^ #afEcma].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   344
    code == #afEcma      ifTrue:[^ #afEcma].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   345
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   346
    code == #datakit      ifTrue:[^ #afDatakit].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   347
    code == #'AF_DATAKIT' ifTrue:[^ #afDatakit].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   348
    code == #afDatakit    ifTrue:[^ #afDatakit].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   349
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   350
    code == #dli       ifTrue:[^ #afDli].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   351
    code == #'AF_DLI'  ifTrue:[^ #afDli].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   352
    code == #afDli     ifTrue:[^ #afDli].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   353
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   354
    code == #lat       ifTrue:[^ #afLat].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   355
    code == #'AF_LAT'  ifTrue:[^ #afLat].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   356
    code == #afLat     ifTrue:[^ #afLat].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   357
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   358
    code == #hylink      ifTrue:[^ #afHylink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   359
    code == #'AF_HYLINK' ifTrue:[^ #afHylink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   360
    code == #afHylink    ifTrue:[^ #afHylink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   361
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   362
    code == #unspec      ifTrue:[^ #afUnspec].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   363
    code == #'AF_UNSPEC' ifTrue:[^ #afUnspec].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   364
    code == #afUnspec    ifTrue:[^ #afUnspec].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   365
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   366
    code == #raw      ifTrue:[^ #afRaw].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   367
    code == #'AF_RAW' ifTrue:[^ #afRaw].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   368
    code == #afRaw    ifTrue:[^ #afRaw].    
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   369
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   370
    "/
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   371
    "/ could someone tell me which symbols are used in ST-80's SocketAddress class ?
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   372
    "/
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   373
    self error:'no more mimicri implemented yet ...'
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   374
!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   375
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   376
domainSymbol
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   377
    "Answer the domain symbol. Subclasses redefine this"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   378
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   379
    self == SocketAddress ifTrue:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   380
        ^ nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   381
    ] ifFalse:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   382
        self subclassResponsibility
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   383
    ]
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   384
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   385
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   386
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   387
    "answer an Array of socket addresses for serviceName on hostName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   388
     Domain, type, protocol may be nil or specify a hint for the socket 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   389
     addresses to be returned."
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   390
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   391
    ^ OperatingSystem socketAccessor 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   392
            getAddressInfo:hostName serviceName:serviceName 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   393
            domain:domainArg type:typeArg protocol:protoArg flags:flags 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   394
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   395
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   396
     self getAddressInfo:'localhost' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   397
            domain:nil type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   398
     self getAddressInfo:'localhost' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   399
            domain:#inet type:#stream protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   400
     self getAddressInfo:'localhost' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   401
            domain:#inet type:#stream protocol:#tcp flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   402
     self getAddressInfo:'blurb.exept.de' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   403
            domain:#inet type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   404
     self getAddressInfo:'1.2.3.4' serviceName:'6' 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   405
            domain:#inet type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   406
     self getAddressInfo:'localhost' serviceName:'echo' 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   407
            domain:#inet6 type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   408
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   409
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   410
1167
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   411
getAddressInfo:hostName serviceName:serviceName type:typeArg protocol:protoArg flags:flags 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   412
    "answer an Array of socket addresses for serviceName on hostName
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   413
     Domain, type, protocol may be nil or specify a hint for the socket 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   414
     addresses to be returned."
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   415
1232
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   416
    ^ self  
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   417
        getAddressInfo:hostName serviceName:serviceName 
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   418
        domain:(self domainCode) type:typeArg protocol:protoArg flags:flags 
1167
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   419
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   420
    "
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   421
     IPSocketAddress getAddressInfo:'localhost' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   422
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   423
     IPSocketAddress getAddressInfo:'localhost' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   424
                     type:#stream protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   425
     IPSocketAddress getAddressInfo:'localhost' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   426
                     type:#stream protocol:#tcp flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   427
     IPSocketAddress getAddressInfo:'blurb.exept.de' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   428
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   429
     IPSocketAddress getAddressInfo:'1.2.3.4' serviceName:'6' 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   430
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   431
     IPSocketAddress getAddressInfo:'localhost' serviceName:'echo' 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   432
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   433
    "
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   434
!
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   435
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   436
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags 
1262
d3daddd36a99 no longer callBack into sockets getHostName/getAddress code.
Claus Gittinger <cg@exept.de>
parents: 1259
diff changeset
   437
    "answer an Array containing the hostName and/or serviceName
d3daddd36a99 no longer callBack into sockets getHostName/getAddress code.
Claus Gittinger <cg@exept.de>
parents: 1259
diff changeset
   438
     for a given socketAddress."
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   439
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   440
    ^ OperatingSystem socketAccessor
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   441
            getNameInfo:socketAddress wantHostName:wantHostName 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   442
            wantServiceName:wantServiceName datagram:useDatagram flags:flags 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   443
    
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   444
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   445
     self getNameInfo:
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   446
         (self getAddressInfo:'localhost' serviceName:'echo' 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   447
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
1262
d3daddd36a99 no longer callBack into sockets getHostName/getAddress code.
Claus Gittinger <cg@exept.de>
parents: 1259
diff changeset
   448
         wantHostName:true wantServiceName:true datagram:false flags:0     
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   449
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   450
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   451
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   452
knownClassFromCode:code
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   453
    "this is a compatibility method;
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   454
     VW expects the internal unix codes here - however, in ST/X,
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   455
     symbols are expected - keeping the numeric values secret (in Socket)"
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   456
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   457
    |cls|
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   458
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   459
    DomainToClassMapping isNil ifTrue:[
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   460
        DomainToClassMapping := IdentityDictionary new
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   461
    ].
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   462
    cls := DomainToClassMapping at:code ifAbsent:nil.
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   463
    cls notNil ifTrue:[^ cls].
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   464
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   465
    code notNil ifTrue:[
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   466
        "/ some are always known...
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   467
        DomainToClassMapping at:#unix put:UDSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   468
        DomainToClassMapping at:#inet put:IPSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   469
        DomainToClassMapping at:#inet6 put:IPv6SocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   470
        DomainToClassMapping at:#appletalk put:AppletalkSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   471
        DomainToClassMapping at:#decnet put:DecNetSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   472
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   473
        self allSubclassesDo:[:aSubClass|
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   474
            (aSubClass domainCode == code
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   475
            or:[aSubClass domainSymbol == code
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   476
            or:[aSubClass obsoleteDomainSymbol == code
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   477
            or:[aSubClass vwDomainSymbol == code]]])
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   478
            ifTrue:[
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   479
                DomainToClassMapping at:code put:aSubClass.
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   480
                ^ aSubClass
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   481
            ].
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   482
        ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   483
    ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   484
    ^ SocketAddress
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   485
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   486
    "
1273
03afdf3f895e addrCache and nameCache must be separate for
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   487
     DomainToClassMapping := nil.
03afdf3f895e addrCache and nameCache must be separate for
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   488
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   489
     self knownClassFromCode:#'AF_UNIX' 
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   490
     self knownClassFromCode:#'AF_INET'
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   491
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   492
     self knownClassFromCode:1
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   493
     self knownClassFromCode:2
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   494
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   495
     self knownClassFromCode:#unix             obsolete ST/X codes
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   496
     self knownClassFromCode:#inet
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   497
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   498
     self knownClassFromCode:#afUnix           visualWorks codes
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   499
     self knownClassFromCode:#afInet
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   500
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   501
!
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   502
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   503
obsoleteDomainSymbol
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   504
    ^ nil
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   505
!
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   506
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   507
peerNameFromPeer:peer
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   508
    ^ peer hostName
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   509
!
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   510
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   511
socketAddressSize
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   512
    "answer the OS specific size of a socket address.
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   513
     Returns nil, if the domain is not supported or invalid."
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   514
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   515
    ^ OperatingSystem socketAddressSizeOfDomain:(self domainSymbol)
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   516
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   517
    "
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   518
     SocketAddress socketAddressSize  
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   519
     UDSocketAddress socketAddressSize  
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   520
     IPSocketAddress socketAddressSize  
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   521
     IPv6SocketAddress socketAddressSize 
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   522
     AppletalkSocketAddress socketAddressSize  
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   523
     DecNetSocketAddress socketAddressSize     
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   524
    "
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   525
!
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   526
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   527
vwDomainSymbol
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   528
    ^ nil
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
! !
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   531
!SocketAddress methodsFor:'accessing'!
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   532
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   533
domainCode
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   534
    ^ self unsignedShortAt:1
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   535
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   536
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   537
domainCode:anInteger
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   538
    self unsignedShortAt:1 put:anInteger
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   539
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   540
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   541
hostAddress:addressBytes
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   542
    "generic method, subclasses usually redefine this"
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   543
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   544
    "/ the first 2-bytes (a short) is the domainCode
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   545
    self replaceBytesFrom:1+2 to:addressBytes size+2 with:addressBytes startingAt:1
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   546
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   547
    "
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   548
     IPSocketAddress hostAddress:#[193 141 12 193] port:80
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   549
    "
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   550
!
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   551
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   552
hostAddress:addressBytes port:portNr
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   553
    self hostAddress:addressBytes.
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   554
    self port:portNr
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   555
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   556
    "
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   557
     IPSocketAddress hostAddress:#[193 141 12 193] port:10
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   558
    "
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   559
!
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   560
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   561
port
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   562
    self subclassResponsibility
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   563
!
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   564
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   565
port:portNr
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   566
    self subclassResponsibility
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   567
! !
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   568
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   569
!SocketAddress methodsFor:'printing & storing'!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   570
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   571
displayString
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   572
    "redefine from Collection"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   573
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   574
    |s|
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   575
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   576
    s := WriteStream on:''.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   577
    self printOn:s.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   578
    ^ s contents.
1333
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   579
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   580
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   581
printAddressOn:arg 
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   582
    "raise an error: must be redefined in concrete subclass(es)"
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   583
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   584
    ^ self subclassResponsibility
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   585
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   586
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   587
printOn:aStream
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   588
    "append a user printed representation of the receiver to aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   589
     The format is suitable for a human - not meant to be read back."
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   590
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   591
    self printOn:aStream withPort:true
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   592
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   593
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   594
printOn:aStream withPort:withPort
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   595
    "append a user printed representation of the receiver to aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   596
     The format is suitable for a human - not meant to be read back."
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   597
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   598
    self printAddressOn:aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   599
    withPort ifTrue:[
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   600
        self printPortOn:aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   601
    ].
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   602
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   603
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   604
printPortOn:aStream 
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   605
    |port|
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   606
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   607
    (port := self port) ~~ 0 ifTrue:[
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   608
        aStream nextPut:$:.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   609
        port printOn:aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   610
    ]
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   611
! !
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   612
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   613
!SocketAddress methodsFor:'private'!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   614
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   615
fromBytes:aByteArray
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   616
    "Copy the internal representation of a SocketAddress to myself
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   617
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   618
     This is an internal interface!!"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   619
1225
8839f52dde96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   620
    self replaceBytesFrom:1 to:(self size) with:aByteArray startingAt:1.
8839f52dde96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   621
8839f52dde96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   622
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   623
! !
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   624
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
!SocketAddress methodsFor:'queries'!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   627
address
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   628
    ^ self subclassResponsibility
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   629
!
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   630
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   631
hostName
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   632
    ^ (self class getNameInfo:self wantHostName:true 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   633
                  wantServiceName:false datagram:false flags:0) first
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   634
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   635
    "
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   636
     (IPSocketAddress hostAddress:#[127 0 0 1]) hostName        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   637
     (IPSocketAddress hostName:'localhost') address        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   638
     (IPSocketAddress hostName:'www.google.com') address        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   639
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   640
     (IPSocketAddress hostAddress:#[127 0 0 1] port:7) hostName        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   641
     (IPSocketAddress hostAddress:#[193 141 12 193] port:10) hostName  
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   642
     (IPSocketAddress hostAddress:#[193 141 12 244]) hostName 
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   643
    "
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   644
!
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   645
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
portOrName
210
d940e6a66526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   647
    ^ self subclassResponsibility
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   648
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   649
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   650
serviceName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   651
    ^ (self class getNameInfo:self wantHostName:false 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   652
                  wantServiceName:true datagram:false flags:0) second
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   653
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   654
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   655
     (IPSocketAddress hostAddress:#[127 0 0 1] port:7) serviceName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   656
     (IPSocketAddress hostAddress:#[193 141 12 193] port:10) serviceName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   657
    "
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
! !
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   660
!SocketAddress class methodsFor:'documentation'!
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   661
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   662
version
1333
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   663
    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.23 2003-10-17 16:43:03 penk Exp $'
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   664
! !