Romeo (7) [Avatar] Offline
#1
Hi,

I followed the steps of the chat program example and realized that it is not fully presented.
Is this intended?

Anyway I'm going to delve into the topics of asynchronous programming and will try to figure out how it might look like when it's finished. smilie

Cheers
dom96 (75) [Avatar] Offline
#2
Hello!

What do you mean by "it is not fully presented?" Could you elaborate?

Thanks
Romeo (7) [Avatar] Offline
#3
The client code isn't fully implemented. The example ends before recieving dispatched messages from the server.
dom96 (75) [Avatar] Offline
#4
Hrm, have you read all of Chapter 3? I think the functionality you are talking about is explained at the end of that chapter, starting at page 118. Is that what you mean?
Romeo (7) [Avatar] Offline
#5
You wrote:
The final results
That’s all there is to it! You can now compile both the server and the client, then run
the server and multiple clients. Sending a message from one client should display it in the
server window but also in the other clients that are connected to the server!


The code of client.nim right before this content doesn't contain echo statements to show the messages sent from the server.
Please Check your client.nim code you presented. It's on page 116 and 117.
dom96 (75) [Avatar] Offline
#6
The code right before The final results subsection does contain an echo statement: echo(parsed.username, " said ", parsed.message) in the connect procedure. Is this what you were looking for?
Romeo (7) [Avatar] Offline
#7
my bad

I didn't use two clients, so i couldn't see the output of the server message in the other client window.

thanks for solving this issue!

I see I need to read your code better and understand the async stuff.
dom96 (75) [Avatar] Offline
#8
I'm glad you got it working!

Maybe there is something I could change in Chapter 3 to make it easier to understand, what do you think?
Romeo (7) [Avatar] Offline
#9
here are my notes:

Listing 3.5 no bold text

\c\l or \c\1 (I know it's line feed but the font is hard to read)

no further mentioning of asyncdispatch module (edit: explanation is given later at page 107. Be redundant.)

3.5.1

"A new problem then arises with the asynchronous version, if the procedure
returns immediately then either there is indeed a new connection which just happened to
be accepted immediately or the procedure would block the application."

Why is it blocking. You said earlier async is not blocking.
The careful reading of the following sentence makes it clear. But the combination of the two is hard to read and understand.
Introduce the problem better. Maybe switch notion of the sentences.
... "the latter" ... "the latter" ...

next block: difference between syncronous and asyncronous accept
implementation of sync is done using net module
------"--------of async -------"---- asyncnet module
Figure shows patterns
make clear what module net and asyncnet have in common and where they differ.
e.g. asyncnet accept produces Future

make clear that doWork() and doWork(socket) are two different tasks which perform

page 107
"The Future type also stores a callback..."
delete word also but make clear that callback is optional and explain what default value of callback is when not explicitly set.

how are futures coupled with the runForever() call.
what future callbacks are concidered to be executed
all previously declared? at what scope?

112 + 116
italic instead of bold in code sample

Don't hesitate to ask me if something is not clear.
dom96 (75) [Avatar] Offline
#10
Looks like the bold in some of the listings is indeed gone. All I can do is pass that on to Manning though (they generated the final PDF).

\c\l or \c\1 (I know it's line feed but the font is hard to read)


hrm, I will make sure to say that it's line feed. The font choice is not mine I'm afraid.

no further mentioning of asyncdispatch module (edit: explanation is given later at page 107. Be redundant.)


Not sure what you mean here. Do you mean that I was mentioning that module without giving an explanation?

Why is it blocking. You said earlier async is not blocking.
The careful reading of the following sentence makes it clear. But the combination of the two is hard to read and understand.
Introduce the problem better. Maybe switch notion of the sentences.


You're right. Will try to reword that sentence. Although it is a bit tough smilie

next block: difference between syncronous and asyncronous accept
implementation of sync is done using net module
------"--------of async -------"---- asyncnet module
Figure shows patterns
make clear what module net and asyncnet have in common and where they differ.
e.g. asyncnet accept produces Future


I do mention that after Figure 3.17:

Of significance is the
fact that the async accept returns a Future type, this type is like a box.


Do you think I should move that above the figure?

make clear that doWork() and doWork(socket) are two different tasks which perform


Thanks, will try to do that.

page 107
"The Future type also stores a callback..."
delete word also but make clear that callback is optional and explain what default value of callback is when not explicitly set.


Will do.

Please let me know if you have any other suggestions! Hope you are finding the book fun to read despite these issues smilie

Romeo (7) [Avatar] Offline
#11
dom96 wrote:
no further mentioning of asyncdispatch module (edit: explanation is given later at page 107. Be redundant.)


Not sure what you mean here. Do you mean that I was mentioning that module without giving an explanation?


Yes


dom96 wrote:
Of significance is the
fact that the async accept returns a Future type, this type is like a box.


Do you think I should move that above the figure?


Yes

dom96 (75) [Avatar] Offline
#12
Okay. Will try to make those fixes as best I can. Thank you for all your feedback!
Romeo (7) [Avatar] Offline
#13
Your're welcome.
396254 (2) [Avatar] Offline
#14
server
[ 2 KB ]
First of all a big thanks! to Dominik Picheta for this awesome book!

But I stuck with the client for this chat application.
The server runs fine and response to any telnet actions: Perfectly.

But my client cant get a connection,
do you have any idea?

exactly this line does not give any response:
await socket.connect( "127.0.0.1", 7687.Port )


while my socket is a new newAsyncSocket()

should be as simple as that, right?


Greets Dave


EDIT: should I create a new Topic?
dom96 (75) [Avatar] Offline
#15
Dave,

Sorry for the delay in this reply.

It seems the problem in your code is at the very bottom, the asyncdispatch.poll() is only called once because it is not indented so it is not under the while true loop. Simply indent it by two spaces and it should work smilie


Hope that helps.
396254 (2) [Avatar] Offline
#16
this was helpful, thanks xD