Skip to content

Commit

Permalink
Issue #43: move SocketStream class>>openConnectionToHost:port:timeout…
Browse files Browse the repository at this point in the history
…: to SocketStream package
  • Loading branch information
dalehenrich committed Dec 11, 2014
1 parent a540447 commit 15dc80d
Show file tree
Hide file tree
Showing 30 changed files with 28 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ accept: aTimeoutInSeconds
newsock := sock accept.
msg := newsock read: 512."

^ self listen: nil acceptingWith: (self speciesForAccept basicNew) for: aTimeoutInSeconds
^ self listen: nil acceptingWith: (self speciesForAccept basicNew) for: aTimeoutInSeconds
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ isConnected
Returns nil if an error occurs."

self isActive ifFalse: [ ^false ].
^ self _zeroArgPrim: 13.
^ self _zeroArgPrim: 13.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ res := true.
(res == nil) ifFalse: [
res := aSocket.
].
^res
^res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*zinc-http
as yet unclassified
openConnectionToHost: host port: portNumber timeout: timeout
| socket |
socket :=SocketStreamSocket newTCPSocket.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ debug
nextPutAll: 'InBuffer data size: ', data asString; cr;
nextPutAll: 'In data (20):', (inBuffer copyFrom: lastRead + 1 to: lastRead + (data min: 20)); cr;
nextPutAll: 'OutBuffer data size: ', (outNextToWrite - 1) asString; cr;
nextPutAll: 'Out data (20):', (outBuffer copyFrom: 1 to: ((outNextToWrite - 1) min: 20)); cr]]

nextPutAll: 'Out data (20):', (outBuffer copyFrom: 1 to: ((outNextToWrite - 1) min: 20)); cr]]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ moveInBufferDown
distanceMoved := lastRead.
lastRead := 0.
inNextToWrite := sz + 1.
^distanceMoved
^distanceMoved
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ peekFor: aCharacterOrByte
nextObject = aCharacterOrByte ifTrue: [
lastRead := lastRead + 1.
^true].
^false
^false
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"class" : {
"on:" : "PaulDeBruicker 03/03/2011 11:49",
"openConnectionToHost:port:timeout:" : "JohanBrichau 06/16/2013 16:20",
"openConnectionToHostNamed:port:" : "PaulDeBruicker 03/12/2011 11:11" },
"instance" : {
"<<" : "PaulDeBruicker 03/03/2011 11:55",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
standardTimeout

^0
^0
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ receiveDataInto: aStringOrByteArray startingAt: aNumber

bytesRead := self readInto: aStringOrByteArray startingAt: aNumber for: b ].

^bytesRead
^bytesRead
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ receiveDataSignallingClosedInto: aStringOrByteArray startingAt: aNumber
whileTrue: [
self waitForData.
bytesRead := self readInto: aStringOrByteArray startingAt: aNumber for: (aStringOrByteArray size -aNumber +1) ].
^bytesRead
^bytesRead
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ receiveDataTimeout: timeout into: aStringOrByteArray startingAt: aNumber
zero (indicating that there was no data available within the given timeout)."

self waitForDataFor: timeout ifClosed: [] ifTimedOut: [].
^self readInto: aStringOrByteArray startingAt: aNumber for: (aStringOrByteArray size - aNumber +1)

^self readInto: aStringOrByteArray startingAt: aNumber for: (aStringOrByteArray size - aNumber +1)
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
as yet unclassified
waitForAcceptFor: timeout
"Wait and accept an incoming connection. Return nil if it falis"
^self waitForConnectionFor: timeout ifTimedOut: [^ nil].


^self waitForConnectionFor: timeout ifTimedOut: [^ nil].
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ waitForDataFor: timeout
^self
waitForDataFor: timeout
ifClosed: [ConnectionClosed signal: 'Connection closed while waiting for data.']
ifTimedOut: [ConnectionTimedOut signal: 'Data receive timed out.']
ifTimedOut: [ConnectionTimedOut signal: 'Data receive timed out.']
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ waitForDataIfClosed: closedBlock
ifTrue: [
^self].

self underlyingSocket readWillNotBlockWithin: -1].
self underlyingSocket readWillNotBlockWithin: -1].
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ setUp
] ensure:[listener close].

clientStream := SocketStream on: clientSocket.
serverStream := SocketStream on: serverSocket.
serverStream := SocketStream on: serverSocket.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ testNextIntoClose
clientStream nextPutAll:'A line of text'; flush.
[(Delay forMilliseconds: 100) wait.
clientStream close] fork.
self assert: ((serverStream next: 100 into: (String new: 100) startingAt: 1) = 'A line of text')
self assert: ((serverStream next: 100 into: (String new: 100) startingAt: 1) = 'A line of text')
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ testNextIntoCloseNonSignaling
[(Delay forMilliseconds: 100) wait.
clientStream close] fork.
self assert: ((serverStream next: 100 into: (String new: 100) startingAt: 1)
= 'A line of text').
= 'A line of text').
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ testUpTo
self assert: (serverStream upTo: Character cr) = 'A line of text'.
[(Delay forSeconds: 1) wait.
clientStream nextPutAll: String cr; flush] fork.
self assert: (serverStream upTo: Character cr) = 'with more text'.
self assert: (serverStream upTo: Character cr) = 'with more text'.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ testUpToAfterCloseSignaling

clientStream nextPutAll:'A line of text'.
clientStream close.
self should: [serverStream upTo: Character cr] raise: ConnectionClosed.
self should: [serverStream upTo: Character cr] raise: ConnectionClosed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ testUpToAll
self assert: (serverStream upToAll: String crlf) = 'A line of text'.
[(Delay forSeconds: 1) wait.
clientStream nextPutAll: String crlf; flush] fork.
self assert: (serverStream upToAll: String crlf) = 'with more text'.
self assert: (serverStream upToAll: String crlf) = 'with more text'.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ testUpToAllAfterCloseSignaling

clientStream nextPutAll:'A line of text'.
clientStream close.
self should: [serverStream upToAll: String crlf] raise: ConnectionClosed.
self should: [serverStream upToAll: String crlf] raise: ConnectionClosed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ testUpToAllTimeout

clientStream nextPutAll: 'A line of text'.
serverStream timeout: 1.
self should: [serverStream upToAll: String crlf] raise: ConnectionTimedOut.
self should: [serverStream upToAll: String crlf] raise: ConnectionTimedOut.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ testUpToEndClose
clientStream nextPutAll:'A line of text'; flush.
[(Delay forMilliseconds: 100) wait.
clientStream close] fork.
self assert: ((serverStream upToEnd) = 'A line of text').
self assert: ((serverStream upToEnd) = 'A line of text').
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ testUpToEndCloseNonSignaling
[(Delay forMilliseconds: 100) wait.
clientStream close] fork.
self assert: ((serverStream upToEnd)
= 'A line of text').
= 'A line of text').
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ testUpToTimeout

clientStream nextPutAll: 'A line of text'.
serverStream timeout: 1.
self should: [serverStream upTo: Character cr] raise: ConnectionTimedOut.
self should: [serverStream upTo: Character cr] raise: ConnectionTimedOut.
2 changes: 1 addition & 1 deletion repository/SocketStream.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'SocketStream-dkh.19' message 'Issue #58: make SocketStream and friends continuation friendly by wrapping GsSocket references in a TransientStackValue. Add ZnTransactionSafeManagingMultiThreadedServer a subclass of ZnManagingMultiThreadedServer where all references to GsSockets are wrapped by a TransientStackValue ... including places where GsSockets are passed as arguments ... this makes the server instance transaction safe, so continuations can be snapped off and transactions can be safely used in delegates ...' id '7e18903d-a920-4db3-8d9e-f8b66e07f4b3' date '12/09/2014' time '11:21:16' author 'dkh' ancestors ((name 'SocketStream-dkh.18' message 'Issue #58: flesh out remote breakpoint work ... cannot switch back to native threads, but for development of servers, it can still be useful ... continue following this thread ...' id 'ccc617a8-4e5f-4778-bdc8-630e9a2edd33' date '12/06/2014' time '15:02:51' author 'dkh' ancestors ((name 'SocketStream-dkh.17' message 'Issue #58: fixed{?) an accept problem whereby an accept error in SocketStreamSocket would lead to an infinite loop creating processes and then running out of memory ... Fix Rest test error ... only pass exceptions in debugMode for ZnServer' id '441ec0b2-3e41-4aea-9553-0c7cebb110cb' date '12/04/2014' time '07:52:22' author 'dkh' ancestors ((name 'SocketStream-dkh.16' message 'fix Issue #51, signal ConnectionClosed when zero bytes returned in SocketStreamSocket>>receiveDataSignallingTimeout:into:startingAt: - 282 run, 267 passes, 0 expected defects, 11 failures, 4 errors, 0 unexpected passes' id '4d54a9e5-1441-4e7e-b1ef-b1eafcf07fb7' date '06/27/2014' time '12:49:39' author 'dkh' ancestors ((name 'SocketStream-dkh.15' message 'improve error logging a bit and take symbol creation out of a loop' id 'd977f852-877f-43e8-9142-2887f783afa3' date '06/06/2014' time '07:53:50' author 'dkh' ancestors ((name 'SocketStream-dkh.14' message 'final touches for Zinc port: 226 run, 222 passes, 4 expected failures, 0 failures, 0 errors, 0 unexpected passes' id '59b64c1b-1da3-4c72-8271-e1f8b8d473ab' date '08/06/2012' time '17:48:24' author 'dkh' ancestors ((name 'SocketStream-dkh.13' message 'additional zinc support' id 'ec318e72-459d-4583-9465-a6b7b93cdd26' date '08/06/2012' time '12:28:12' author 'dkh' ancestors ((name 'SocketStream-PaulDeBruicker.12' message 'added a timeout for #accept. use #accept:' id 'f72cef29-376f-4345-93d2-290a478f3594' date '04/13/2011' time '11:28:17' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.11' message 'Revised so now all the tests pass. ' id 'e0ddf9f3-a526-4dfb-a77e-19ae15ba3478' date '04/12/2011' time '16:16:59' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.10' message 'Moved some extensions from Zinc to SocketStream' id '17ebfec6-9e85-45f0-b03e-b4398798b0e2' date '04/10/2011' time '11:32:48' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.9' message 'forgot to include SocketStreamSocket>>#destroy' id '5719a133-c336-4394-9eef-dd7c81910bc7' date '04/08/2011' time '18:32:46' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.8' message 'Changed to remove the testing of whether or not the socket isConnected in waitForAcceptFor:' id '6a99b6a9-6294-47e9-abd2-f6ce7e9341fa' date '04/08/2011' time '10:22:35' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.7' message 'Left a halt in inadvertently ' id 'c202e09a-80d4-4ea9-b26a-9c94fe6096e5' date '04/07/2011' time '20:04:06' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.6' message 'Had a bug where the socket waited at least until the value of standardTimeout before returning data. Things that used to take at least 45 seconds now take a fraction of a second. ' id '36f48d31-f1f1-44fd-a589-13efe4554468' date '04/07/2011' time '20:00:17' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.5' message 'initial release. Works with Chronos, passes 12 of 14 tests. Does not pass those tests which check that the appropriate error is raised when an error occurs. ' id 'fb5fc467-fbb2-4d60-8a50-22aa951cfd22' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.4' message 'initial release. Works with Chronos, passes 12 of 14 tests. Does not pass those tests which check that the appropriate error is raised when an error occurs. ' id 'e78a7cda-b5f1-4527-be4d-c4b9fa9c2ae0' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.3' message 'Added SocketStreamSocket>>accept' id '0e413f62-ed07-487d-bb4a-c4c7081c7674' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.2' message 'Subclassed SpSocket rather than add a bunch of overrides and extensions' id '18cd025b-b808-4e4d-874f-d8a829c84dc7' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.1' message 'Renamed in anticipation of uploading to Gemsource.' id '22385bc5-30f4-4c64-8e9f-8bb863e432b2' date '03/09/2011' time '00:00:00' author 'PaulDeBruicker' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'SocketStream-dkh.20' message 'Issue #43: move SocketStream class>>openConnectionToHost:port:timeout: to SocketStream package' id 'df32d528-9c73-435f-9b88-35f3d5a2eee0' date '12/11/2014' time '14:57:42' author 'dkh' ancestors ((name 'SocketStream-dkh.19' message 'Issue #58: make SocketStream and friends continuation friendly by wrapping GsSocket references in a TransientStackValue. Add ZnTransactionSafeManagingMultiThreadedServer a subclass of ZnManagingMultiThreadedServer where all references to GsSockets are wrapped by a TransientStackValue ... including places where GsSockets are passed as arguments ... this makes the server instance transaction safe, so continuations can be snapped off and transactions can be safely used in delegates ...' id '7e18903d-a920-4db3-8d9e-f8b66e07f4b3' date '12/09/2014' time '11:21:16' author 'dkh' ancestors ((name 'SocketStream-dkh.18' message 'Issue #58: flesh out remote breakpoint work ... cannot switch back to native threads, but for development of servers, it can still be useful ... continue following this thread ...' id 'ccc617a8-4e5f-4778-bdc8-630e9a2edd33' date '12/06/2014' time '15:02:51' author 'dkh' ancestors ((name 'SocketStream-dkh.17' message 'Issue #58: fixed{?) an accept problem whereby an accept error in SocketStreamSocket would lead to an infinite loop creating processes and then running out of memory ... Fix Rest test error ... only pass exceptions in debugMode for ZnServer' id '441ec0b2-3e41-4aea-9553-0c7cebb110cb' date '12/04/2014' time '07:52:22' author 'dkh' ancestors ((name 'SocketStream-dkh.16' message 'fix Issue #51, signal ConnectionClosed when zero bytes returned in SocketStreamSocket>>receiveDataSignallingTimeout:into:startingAt: - 282 run, 267 passes, 0 expected defects, 11 failures, 4 errors, 0 unexpected passes' id '4d54a9e5-1441-4e7e-b1ef-b1eafcf07fb7' date '06/27/2014' time '12:49:39' author 'dkh' ancestors ((name 'SocketStream-dkh.15' message 'improve error logging a bit and take symbol creation out of a loop' id 'd977f852-877f-43e8-9142-2887f783afa3' date '06/06/2014' time '07:53:50' author 'dkh' ancestors ((name 'SocketStream-dkh.14' message 'final touches for Zinc port: 226 run, 222 passes, 4 expected failures, 0 failures, 0 errors, 0 unexpected passes' id '59b64c1b-1da3-4c72-8271-e1f8b8d473ab' date '08/06/2012' time '17:48:24' author 'dkh' ancestors ((name 'SocketStream-dkh.13' message 'additional zinc support' id 'ec318e72-459d-4583-9465-a6b7b93cdd26' date '08/06/2012' time '12:28:12' author 'dkh' ancestors ((name 'SocketStream-PaulDeBruicker.12' message 'added a timeout for #accept. use #accept:' id 'f72cef29-376f-4345-93d2-290a478f3594' date '04/13/2011' time '11:28:17' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.11' message 'Revised so now all the tests pass. ' id 'e0ddf9f3-a526-4dfb-a77e-19ae15ba3478' date '04/12/2011' time '16:16:59' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.10' message 'Moved some extensions from Zinc to SocketStream' id '17ebfec6-9e85-45f0-b03e-b4398798b0e2' date '04/10/2011' time '11:32:48' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.9' message 'forgot to include SocketStreamSocket>>#destroy' id '5719a133-c336-4394-9eef-dd7c81910bc7' date '04/08/2011' time '18:32:46' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.8' message 'Changed to remove the testing of whether or not the socket isConnected in waitForAcceptFor:' id '6a99b6a9-6294-47e9-abd2-f6ce7e9341fa' date '04/08/2011' time '10:22:35' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.7' message 'Left a halt in inadvertently ' id 'c202e09a-80d4-4ea9-b26a-9c94fe6096e5' date '04/07/2011' time '20:04:06' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.6' message 'Had a bug where the socket waited at least until the value of standardTimeout before returning data. Things that used to take at least 45 seconds now take a fraction of a second. ' id '36f48d31-f1f1-44fd-a589-13efe4554468' date '04/07/2011' time '20:00:17' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.5' message 'initial release. Works with Chronos, passes 12 of 14 tests. Does not pass those tests which check that the appropriate error is raised when an error occurs. ' id 'fb5fc467-fbb2-4d60-8a50-22aa951cfd22' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.4' message 'initial release. Works with Chronos, passes 12 of 14 tests. Does not pass those tests which check that the appropriate error is raised when an error occurs. ' id 'e78a7cda-b5f1-4527-be4d-c4b9fa9c2ae0' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.3' message 'Added SocketStreamSocket>>accept' id '0e413f62-ed07-487d-bb4a-c4c7081c7674' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.2' message 'Subclassed SpSocket rather than add a bunch of overrides and extensions' id '18cd025b-b808-4e4d-874f-d8a829c84dc7' date '03/12/2011' time '00:00:00' author 'PaulDeBruicker' ancestors ((name 'SocketStream-PaulDeBruicker.1' message 'Renamed in anticipation of uploading to Gemsource.' id '22385bc5-30f4-4c64-8e9f-8bb863e432b2' date '03/09/2011' time '00:00:00' author 'PaulDeBruicker' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion repository/Zinc-HTTP.package/monticello.meta/version

Large diffs are not rendered by default.

0 comments on commit 15dc80d

Please sign in to comment.