[Sbcl-help] Deadlock with simple client/server sockets application

5 views
Skip to first unread message

Nicholas Mills

unread,
Jul 18, 2012, 4:18:08 PM7/18/12
to sbcl...@lists.sourceforge.net
All,

I am trying to write a simple client/server program using
sb-bsd-sockets but I am experiencing deadlock. I am calling
(finish-output) on the stream after each write. The test program is
attached. My program has the following semantics:

Server:
1. Create socket
2. Bind to 127.0.0.1:8675
3. Listen, Accept
4. Read from the client (blocking)
5. Write to the client
6. Cleanup

Client:
1. Create socket
2. Connect to 127.0.0.1:8675
3. Write to the server
4. Read from the server (blocking)
5. Cleanup

I have tested on the following machines:

Machine 1: SBCL 1.0.57, CentOS release 6.2 (Final), Linux
2.6.32-220.17.1.el6.x86_64
Machine 2: SBCL 1.0.38-3.el6, CentOS release 6.3 (Final), Linux
2.6.32-279.1.1.el6.x86_64

I receive the following output:

Server:
$ sbcl --noinform --no-userinit --no-sysinit --load test.lisp --eval
'(server-test :full)'
connected.

Client:
$ sbcl --noinform --no-userinit --no-sysinit --load test.lisp --eval
'(client-test :full)'
connected.
wrote: (10 9 8 Z Y X)


Thank you all,

Nick Mills
test.lisp

Stig Hemmer

unread,
Jul 18, 2012, 5:42:06 PM7/18/12
to nlm...@clemson.edu, sbcl...@lists.sourceforge.net
A bit of testing with READ-CHAR shows that the message has been sent
in full, but that the server hangs on READ.

Apparently READ is expecting something more after the final
)-character of the list. I don't understand why.

However, the problem can be solved by sending a newline character from
the client, using for example TERPRI.

I haven't tested, but you might need to do the same on the server
response. (Though closing the socket *should* satisfy READ)

Good luck!

Stig Hemmer

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Sbcl-help mailing list
Sbcl...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help
Reply all
Reply to author
Forward
0 new messages