The Trunk: Network-eem.242.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Network-eem.242.mcz

commits-2
Eliot Miranda uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-eem.242.mcz

==================== Summary ====================

Name: Network-eem.242
Author: eem
Time: 25 September 2020, 1:16:43.056168 pm
UUID: 555fce79-4be7-49f4-a0d6-b976a406942e
Ancestors: Network-eem.241

Sockets:
Add an inst var to Socket to remember the address family (INET4 vs INET6) for a new-style socket.
Add family-specific lookup facilities to NetNameResolver.

=============== Diff against Network-eem.241 ===============

Item was added:
+ ----- Method: NetNameResolver class>>addressForName:family: (in category 'lookups') -----
+ addressForName: hostName family: addressFamily
+ "NetNameResolver addressForName: 'squeak.org' family: SocketAddressInformation addressFamilyINET4"
+ "NetNameResolver addressForName: 'localhost' family: SocketAddressInformation addressFamilyINET6"
+ "NetNameResolver addressForName: '127.0.0.1' family: SocketAddressInformation addressFamilyINET6"
+ | addresses |
+ self useOldNetwork ifTrue:
+ [^self oldAddressForName: hostName].
+ addresses := self addressesForName: hostName family: addressFamily.
+ ^addresses
+ ifEmpty: [nil]
+ ifNotEmpty: [addresses first socketAddress]!

Item was changed:
  ----- Method: NetNameResolver class>>addressesForName: (in category 'lookup') -----
  addressesForName: hostName
  "NetNameResolver addressesForName: 'impara.de' "
 
+ ^SocketAddressInformation
- | addresses |
- addresses := SocketAddressInformation
  forHost: hostName
  service: ''
  flags: 0
  addressFamily: 0
  socketType: SocketAddressInformation socketTypeStream
+ protocol: SocketAddressInformation protocolTCP!
- protocol: SocketAddressInformation protocolTCP.
- ^addresses!

Item was added:
+ ----- Method: NetNameResolver class>>addressesForName:family: (in category 'lookup') -----
+ addressesForName: hostName family: addressFamily
+ "NetNameResolver
+ addressesForName: 'squeak.org'
+ family: SocketAddressInformation addressFamilyINET4"
+ "NetNameResolver
+ addressesForName: 'impara.de'
+ family: SocketAddressInformation addressFamilyINET6"
+
+ ^SocketAddressInformation
+ forHost: hostName
+ service: ''
+ flags: 0
+ addressFamily: addressFamily
+ socketType: SocketAddressInformation socketTypeStream
+ protocol: SocketAddressInformation protocolTCP!

Item was changed:
  Object subclass: #Socket
+ instanceVariableNames: 'semaphore socketHandle readSemaphore writeSemaphore family'
- instanceVariableNames: 'semaphore socketHandle readSemaphore writeSemaphore'
  classVariableNames: 'Connected DeadServer DefaultReceiveBufferSize DefaultSendBufferSize InvalidSocket MaximumReadSemaphoreWaitTimeout OtherEndClosed Registry TCPSocketType ThisEndClosed UDPSocketType Unconnected WaitingForConnection'
  poolDictionaries: ''
  category: 'Network-Kernel'!
 
  !Socket commentStamp: 'gk 12/13/2005 00:43' prior: 0!
  A Socket represents a network connection point. Current sockets are designed to support the TCP/IP and UDP protocols. Sockets are the lowest level of networking object in Squeak and are not normally used directly. SocketStream is a higher level object wrapping a Socket in a stream like protocol.
 
  ProtocolClient and subclasses are in turn wrappers around a SocketStream to provide support for specific network protocols such as POP, NNTP, HTTP, and FTP.!

Item was added:
+ ----- Method: Socket>>addressFamily (in category 'accessing') -----
+ addressFamily
+ ^family!

Item was changed:
  ----- Method: Socket>>initialize:family: (in category 'initialize-destroy') -----
+ initialize: socketType family: addressFamily
- initialize: socketType family: family
  "Initialize a new socket handle. If socket creation fails, socketHandle will be set to nil."
 
+ family := addressFamily.
  NetNameResolver useOldNetwork ifTrue: [ ^self initialize: socketType ].
  self initializeSocketHandleUsing: [ :semaIndex :readSemaIndex :writeSemaIndex |
  self primSocketCreateNetwork: family
  type: socketType
  receiveBufferSize: DefaultReceiveBufferSize
  sendBufSize: DefaultSendBufferSize
  semaIndex: semaIndex
  readSemaIndex: readSemaIndex
  writeSemaIndex: writeSemaIndex ]!

Item was changed:
  ----- Method: Socket>>waitForDataIfClosed: (in category 'waiting') -----
  waitForDataIfClosed: closedBlock
  "Wait indefinitely for data to arrive.  This method will block until
  data is available or the socket is closed."
 
+ [socketHandle ifNil: [^closedBlock value ].
+ (self primSocketReceiveDataAvailable: socketHandle) ifTrue: [ ^self ].
+ self isConnected ifFalse: [ ^closedBlock value ].
+ "ul 8/13/2014 21:16
+  Providing a maximum for the time for waiting is a workaround for a VM bug which
+  causes sockets waiting for data forever in some rare cases, because the semaphore
+  doesn't get signaled. Replace the ""waitTimeoutMSecs: self class maximumReadSemaphoreWaitTimeout""
+  part with ""wait"" when the bug is fixed."
+ readSemaphore waitTimeoutMSecs: self class maximumReadSemaphoreWaitTimeout ] repeat!
- socketHandle ifNil: [ ^closedBlock value ].
- [
- (self primSocketReceiveDataAvailable: socketHandle) ifTrue: [ ^self ].
- self isConnected ifFalse: [ ^closedBlock value ].
- "ul 8/13/2014 21:16
-  Providing a maximum for the time for waiting is a workaround for a VM bug which
-  causes sockets waiting for data forever in some rare cases, because the semaphore
-  doesn't get signaled. Replace the ""waitTimeoutMSecs: self class maximumReadSemaphoreWaitTimeout""
-  part with ""wait"" when the bug is fixed."
- readSemaphore waitTimeoutMSecs: self class maximumReadSemaphoreWaitTimeout ] repeat!