Socket.st
changeset 1110 0876a3d30fd2
parent 1035 5b0605675dc6
child 1112 b30ccede6078
equal deleted inserted replaced
1109:3dd9d0a420a1 1110:0876a3d30fd2
  2169      Socket typeOfProtocol:(Socket protocolOfService:'nntp')
  2169      Socket typeOfProtocol:(Socket protocolOfService:'nntp')
  2170      Socket typeOfProtocol:(Socket protocolOfService:'echo')
  2170      Socket typeOfProtocol:(Socket protocolOfService:'echo')
  2171     "
  2171     "
  2172 ! !
  2172 ! !
  2173 
  2173 
       
  2174 !Socket methodsFor:'Compatibility - Dolphin'!
       
  2175 
       
  2176 setReceiveTimeout: milliseconds
       
  2177     self receiveTimeout:(milliseconds / 1000)
       
  2178 !
       
  2179 
       
  2180 setSendTimeout: milliseconds
       
  2181     self sendTimeout:(milliseconds / 1000)
       
  2182 ! !
       
  2183 
  2174 !Socket methodsFor:'Compatibility - ST80'!
  2184 !Socket methodsFor:'Compatibility - ST80'!
  2175 
  2185 
  2176 acceptNonBlock
  2186 acceptNonBlock
  2177     ^ self accept
  2187     ^ self accept
  2178 !
  2188 !
  2247 peerName
  2257 peerName
  2248     "return my peer (i.e. ipAddr + port);
  2258     "return my peer (i.e. ipAddr + port);
  2249      May return nil if not yet setup completely."
  2259      May return nil if not yet setup completely."
  2250 
  2260 
  2251     ^ self getPeer
  2261     ^ self getPeer
       
  2262 ! !
       
  2263 
       
  2264 !Socket methodsFor:'accessing'!
       
  2265 
       
  2266 localAddress
       
  2267 	"Answer an InternetAddress representing the address of the peer machine."
       
  2268 
       
  2269 	| winSockAddr winSockAddrLen result |
       
  2270 	#swAdded.
       
  2271 	winSockAddr := SOCKADDR_IN new.
       
  2272 	winSockAddrLen := SDWORD new.
       
  2273 	winSockAddrLen value: winSockAddr byteSize.
       
  2274 	result := WSockLibrary default 
       
  2275 				getsockname: self asParameter
       
  2276 				name: winSockAddr
       
  2277 				namelen: winSockAddrLen.
       
  2278 	result = -1 ifTrue: [self error].
       
  2279 	^InternetAddress ipAddress: winSockAddr sin_addr
       
  2280 !
       
  2281 
       
  2282 swazooLogStream
       
  2283 	#swAdded.
       
  2284 	^SwazooLoggingStream socket: self
       
  2285 !
       
  2286 
       
  2287 swazooStream
       
  2288 	#swAdded.
       
  2289 	^SwazooStream socket: self
  2252 ! !
  2290 ! !
  2253 
  2291 
  2254 !Socket methodsFor:'datagram transmission'!
  2292 !Socket methodsFor:'datagram transmission'!
  2255 
  2293 
  2256 receiveBuffer:aDataBuffer start:startIndex for:nBytes
  2294 receiveBuffer:aDataBuffer start:startIndex for:nBytes
  4495     "return true, if the receiver has a connection"
  4533     "return true, if the receiver has a connection"
  4496 
  4534 
  4497     ^ filePointer notNil
  4535     ^ filePointer notNil
  4498 !
  4536 !
  4499 
  4537 
       
  4538 isConnected
       
  4539     "return true, if the receiver has a connection"
       
  4540 
       
  4541     ^ self isActive
       
  4542       and:[port notNil
       
  4543       and:[peerName notNil]]
       
  4544 !
       
  4545 
  4500 port
  4546 port
  4501     "return the port number (or name for unix-sockets) to which the socket is bound"
  4547     "return the port number (or name for unix-sockets) to which the socket is bound"
  4502 
  4548 
  4503     |p|
  4549     |p|
  4504 
  4550 
  5112 ! !
  5158 ! !
  5113 
  5159 
  5114 !Socket class methodsFor:'documentation'!
  5160 !Socket class methodsFor:'documentation'!
  5115 
  5161 
  5116 version
  5162 version
  5117     ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.162 2002-04-09 14:58:01 stefan Exp $'
  5163     ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.163 2002-11-04 09:15:37 cg Exp $'
  5118 ! !
  5164 ! !