[Q] [EchoServer] Forked process does not work

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

[Q] [EchoServer] Forked process does not work

Chun, Sungjin
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Attached file is modified version of Robin Redeker(Thanks :-). And
during some experimentation I found something wierd in GST.

If I replace SocketTest>>start with [self run] fork, then this server
does not work. If client connected, nothing happens, I have to do
something on prompt like 'a' printNl!, which seems that only foreground,
input processing process does receive enough cpu time cycle.

Sorry for my poor english. And thanks in advance.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFQamAQqspS1+XJHgRAiLXAKC9b75PSYeM7KTdBuMUcvaAqjgR4QCgsToc
snEDaEcTX8qzRHzzb+toPaM=
=BJ9S
-----END PGP SIGNATURE-----

"Filed out from GNU Smalltalk version 2.2b on 26-Oct-2006  10:30:02"!

Smalltalk.Object subclass: #SocketTest
        instanceVariableNames: 'buffer socket '
        classVariableNames: ''
        poolDictionaries: ''
        category: nil!

SocketTest comment:
nil!

!SocketTest class methodsFor: 'instance creation'!

new
  | n |
  n := super new.
  n init.
  ^n
! !

!SocketTest methodsFor: 'basic'!

handle: sock
   | hunk |
   [
      [
         [ sock atEnd ] whileFalse: [
             "buffer := buffer, (sock nextHunk)."
             hunk := sock nextHunk.
             "sock nextPutAll: buffer."
             sock nextPutAll: 'HTTP/1.0 200 OK'; nl.
             sock nextPutAll: 'Connection: close'; nl.
             sock nextPutAll: 'ETag: "-2113059554"'; nl.
             sock nextPutAll: 'Accept-Ranges: bytes'; nl.
             sock nextPutAll: 'Last-Modified: Fri, 27 Oct 2006 05:23:31 GMT'; nl.
             sock nextPutAll: 'Content-Length: 17'; nl.
             sock nextPutAll: 'Date: Fri, 27 Oct 2006 05:23:37 GMT'; nl.
             sock nextPutAll: 'Server: lighttpd/1.4.11'; nl; nl.
             sock nextPutAll: hunk.
             sock flush.
             sock close.
         ].
      ] ensure: [ sock close ]
   ] fork
!

init
   buffer := String new
!

run
   'Starting server...' displayNl.
   socket := TCP.ServerSocket port: 12345.
   socket isNil ifTrue: [ self error: 'couldn''t create ServerSocket!' ].
   [
      socket waitForConnection.
      "'Got connection!' displayNl."
      self handle: (socket accept)
   ] repeat
!

start
   self run.
   "[self run] fork."
!

stop
   socket close
! !

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [Q] [EchoServer] Forked process does not work

Robin Redeker-2
On Fri, Oct 27, 2006 at 03:38:56PM +0900, Sungjin Chun wrote:

> Hi,
>
> Attached file is modified version of Robin Redeker(Thanks :-). And
> during some experimentation I found something wierd in GST.
>
> If I replace SocketTest>>start with [self run] fork, then this server
> does not work. If client connected, nothing happens, I have to do
> something on prompt like 'a' printNl!, which seems that only foreground,
> input processing process does receive enough cpu time cycle.
>

I've experienced something similar when using the gst command line REPL
with something like this: Smalltalk at: #x put: ([SocketText start] fork)!
But the server reacted when i pressed return sometimes on the REPL, so
that the promt refreshes.

cu,
Robin


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