cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.97k stars 983 forks source link

Fixing Section 4.9 Example: Socket Operations in the Chez Scheme User's Guide for Version 9.5.8 #701

Open namin opened 1 year ago

namin commented 1 year ago

It seems at least like the client code (sample session) doesn't match the library.

I get the error:

Exception in c-write: invalid foreign-procedure argument "(let ((x 3)) x)\n"

I changed the c-write signature in the socket library in Scheme to take utf-8 instead of u8*, and also adjusted the other parameters to match the C code.

When using c-read, I need to pass in a mutable buffer, so I do that in the client code.

In the client code, I provide the start parameter as 0 both when calling c-write and c-read.

I also commented out the first get, which seems blocking.

You can see the diff here: https://github.com/namin/chezscheme-socket/commit/d4c7bfac6a108bb513d7af81c001adfd455df558

Thanks.

jltaylor-us commented 1 year ago

A more up-to-date version of that example can be found in examples/socket.ss.