List Info

Thread: Any simple example or documentation on NetServer code?




Any simple example or documentation on NetServer code?
user name
2006-10-26 10:28:19
> Sorry, i got the topic somehow wrong in the other
posts. Sorry for
> being so noisy. I most should've posted the stuff more
as a question
> of mine than an answer 
>   
No problem.  I guess Sungjin can do the same as you did --
browse the 
code for NetServer -- and rewrite the code with the
NetServer 
architecture (which is a set of abstract classes that take
care 
themselves of the forking), while still starting from
somewhere.

You have to subclass NetServer and NetSession.  NetServer
listens on a 
socket and creates NetSessions; NetSession parses requests
and passes 
them back to NetServer.  (Note that the request is an
arbitrary object, 
so you can pass in your case for example an association like

socket->data and do "request key nextPutAll: request
value")

Then, you implement your server by overriding this methods:

- in the EchoServer, #newSession (answering
"EchoSession new" in your 
case) and #respondTo: (which takes the request association
and answers 
as I outlined above)

- in the EchoSession, #next (which might be as easy as
"self 
socket->self socket nextHunk")

Note that examples and documentation are what is badly
needed.  Sending 
them will never hurt.

Paolo



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )