Hi Bernard,
Post by b***@gmail.comMy Smalltalk program needs to receive two unsolicited packet (a heartbeat and an action message). I will be sending three different packet requests to their program. Each of these send and receive will require an explicit response to acknowledge that you have received and understand the data, ie, handshake. If I am using one port I have to keep the socket open all the time. The issue I see is how to receive the packet without polling (whileTrue loop). In TobSockets I could create a server socket and define my clientBlock but if I have to use the same socket for sending as well this would be a little tricky. My code upon launch would connect to the vendor's software and establish the connection.
I don't think your side can act as both a server and a client, not do I
think you want to. You say your code upon launch would connect to the
vendor's software, I would start there. Use SocketSet as a client side and
connect to the vendor's software on the agreed upon port.
You can then put up a read on that connection. If you need to, you can set
a timeout on the read. If the heartbeat or action message doesn't show up
one time, you can kill the connection and re-connect. I have rewritten
some of the SocketSet code in this area and will share it if you need it.
If you only send messages to the vendor's software in response to heartbeat
or action message, everything is fine. But if you need to send a message
while a read is up, things get tricky. You would have to kill the read and
then send your message. I don't recommend this if it can at all be
avoided. Be absolutely sure you need to break into a read before trying to
do so. Maybe you could wait to send your message until just after getting
a heartbeat or other message from the vendor's software.
If you really need to send messages at any time, I wouldn't use the
SocketSet timeout but would peak to see if there is anything ready to read
and write your own timeout code (not that hard to do). I know you want to
avoid polling but it really isn't that bad and will probably be the easiest
thing to do.
Let me know if you want more help with details.
Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:***@Keystone-Software.com http://www.Keystone-Software.com