<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-04-27 13:26 GMT-04:00 Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Ian,<br></blockquote><div><br></div><div>Hi again,</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I see a few issues with the code you attached:<br>
- #receiveData will only read at most 2000 bytes and will get the content of one or maybe more TCP packets. But if you have larger packets enabled on your network, it'll only read a partial packet. I suggest you use SocketStream, because you don't want to process packets but a stream of data.<br></blockquote><div><br></div><div>SocketStream seems like a good idea.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- if you want to handle multiple requests through a single TCP connection, you should come up with a protocol to separate the different calls, so that you know where a request starts and ends. For example, you could just write 2 bytes, the length of the source string and then the source string itself. Or you could use Smalltalk's chunk format. Or whatever you come up with that fits your needs.<br></blockquote><div><br></div><div>Yes, I was thinking about sending length of the source code first. That would certainly allow SyntaxServer to know how many bytes to expect.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- locking is unnecessary for a single variable. As long as there's no real message send (non-failing primitives are not real sends) or backwards jump (loop) in your code, it'll be thread safe.</blockquote><div><br></div><div>It was actually in a Pharo Sockets tutorial by Noury Bouraqadi and Luc Fabresse.</div><div><br></div><div>Thanks for your feedback!</div><div><br></div><div>Ian</div></div></div></div>