Doru,

I meant: look at ZnServer and friends for inspiration, not to solve the problem 
of how to write a simple TCP server.

If you do just: ZnServer startDefaultOn: 1701 and then talk HTTP over telnet, 
it will work as expected:

$ telnet 127.0.0.1 1701
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1 

HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
Content-Length: 1195
Date: Fri, 24 Feb 2012 12:51:03 GMT
Server: Zinc HTTP Components 1.0

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
<head>
<title>Zinc HTTP Components</title>
<style type="text/css">
body {
  color: black;
….


Writing your own delegate means handling HTTP requests and answering with HTTP 
responses. (Zn contains a lot of these). 

But I am not sure that you should do that for your problem, on one hand it 
might be overkill, on the other hand, HTTP _is_ one of the easiest protocols, 
not need to invent something new. If you use HTTP, you get all you need with Zn.

The question is: what is on the other side ? what is the client ?

Sven

On 24 Feb 2012, at 13:20, Tudor Girba wrote:

> Hi,
> 
> I advanced a bit, but I am still in trouble.
> 
> I just want to get a communication going with a simple telnet app.
> Here is what I did:
> 
> In Pharo:
> ZnMultiThreadedServer startDefaultOn: 1701.
> ZnMultiThreadedServer default
>       delegate: PXSLogDelegate new.
> ZnMultiThreadedServer default
>       log addListener: ZnTranscriptLogger new..
> 
> In the Windows 7 command line:
> - telnet localhost 1701
> - then press ENTER
> 
> And in the Transcript I get:
> 2012-02-24 13:16:57 201678 D Executing request/response loop
> 2012-02-24 13:17:02 201678 D ZnUnknownHttpMethod while reading request
> 2012-02-24 13:17:02 201678 D Closing stream
> 
> The problem is that I do not want to get as high as http. Is there a
> way to get this working, or is Zinc too high level for this task?
> 
> I forgot to mention that I am a total newbie in this area :)
> 
> Cheers,
> Doru
> 
> 
> On Fri, Feb 24, 2012 at 10:56 AM, Tudor Girba <[email protected]> wrote:
>> Thanks, Sven. Will do.
>> 
>> Cheers,
>> Doru
>> 
>> 
>> 
>> On Fri, Feb 24, 2012 at 10:37 AM, Sven Van Caekenberghe <[email protected]> 
>> wrote:
>>> Doru,
>>> 
>>> On 24 Feb 2012, at 10:14, Tudor Girba wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I would need to listen to a TCP/IP port and receive plain text. What
>>>> is the way to do that in Pharo these days?
>>>> 
>>>> Cheers,
>>>> Doru
>>>> 
>>>> --
>>>> www.tudorgirba.com
>>>> 
>>>> "Every thing has its own flow"
>>> 
>>> Have a look at the ZnServer hierarchy, specifically ZnSingleThreadedServer 
>>> which does not spawn threads for each incoming request (not used as such in 
>>> Zn, but easier to understand) and ZnMultiThreadedServer which does spawn 
>>> threads for each incoming request (the current default in Zn). Start with 
>>> #listenLoop. The code is slightly more complicated that example code 
>>> because of all the error handling, but I am sure you will be able to read 
>>> it.
>>> 
>>> HTH,
>>> 
>>> Sven
>>> 
>>> --
>>> Sven Van Caekenberghe
>>> http://stfx.eu
>>> Smalltalk is the Red Pill
>>> 
>>> 
>> 
>> 
>> 
>> --
>> www.tudorgirba.com
>> 
>> "Every thing has its own flow"
> 
> 
> 
> -- 
> www.tudorgirba.com
> 
> "Every thing has its own flow"
> 


Reply via email to