1. It doesn't close the client (source) socket when the server (dest) socket closes.
 2. The loop is CPU intensive

You can use two processes.

p1 := [
    source ensureReadable.
    source isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
    dest nextPutAllFlush: source nextHunk ] newProcess.
p2 := [
    dest ensureReadable.
    dest isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
    source nextPutAllFlush: dest nextHunk ] newProcess.

p1 resume.
p2 resume


In 3.0c there is no #nextHunk, so you can use StreamSocket to remove the write buffering and do

p1 := [
    source ensureReadable.
    source isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
    source nextAvailablePutAllOn: dest ] newProcess.
p2 := [
    dest ensureReadable.
    dest isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
    dest nextAvailablePutAllOn: source ] newProcess.

p1 resume.
p2 resume


This has better performance because it does not do unnecessary copies and creation of objects.

Paolo


_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to