[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [Q] [EchoServer] Forked process does not work
From: |
Sungjin Chun |
Subject: |
[Help-smalltalk] [Q] [EchoServer] Forked process does not work |
Date: |
Fri, 27 Oct 2006 15:38:56 +0900 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060922) |
-----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] [Q] [EchoServer] Forked process does not work,
Sungjin Chun <=