Discussion:
Socket
(too old to reply)
b***@gmail.com
2013-12-09 01:09:20 UTC
Permalink
We are using VA Smalltalk 8.5 and TobSockets in the normal client/server sense.
However, I need to communicate with a vendor software using the same port for client and server TCP packets. Don't ask me to change the design it is not my decision.

Can you Smalltalkers provide some advice if there is a good way to do this in TobSockets? I don't really want to play around in SciScoket. Thanks!

Bernard
Louis LaBrunda
2013-12-09 15:07:06 UTC
Permalink
Hi Bernard,

I use Totally Objects SocketSet a lot, so maybe I can help. Can you tell
more about what you are trying to do. Is your code connecting to the
vendor software or is it connecting to you (or both)? In other words are
you running as the server side or client side?

Lou
Post by b***@gmail.com
We are using VA Smalltalk 8.5 and TobSockets in the normal client/server sense.
However, I need to communicate with a vendor software using the same port for client and server TCP packets. Don't ask me to change the design it is not my decision.
Do you mean you want to avoid the reassigning of ports that goes on when
someone connects into your server side?
Post by b***@gmail.com
Can you Smalltalkers provide some advice if there is a good way to do this in TobSockets? I don't really want to play around in SciScoket. Thanks!
Bernard
P.S. You should try to post this question on the VA Smalltalk new group:
https://groups.google.com/forum/#!forum/va-smalltalk.
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:***@Keystone-Software.com http://www.Keystone-Software.com
b***@gmail.com
2013-12-09 16:14:34 UTC
Permalink
Hi Louis,

My 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.

Thanks.
Bernard
Louis LaBrunda
2013-12-09 16:49:26 UTC
Permalink
Hi Bernard,
Post by b***@gmail.com
My 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
b***@gmail.com
2013-12-09 19:46:21 UTC
Permalink
This post might be inappropriate. Click to display it.
Louis LaBrunda
2013-12-09 20:43:55 UTC
Permalink
Sounds about right.

Lou
Post by b***@gmail.com
Thanks Lou.
I'll create the client socket upon client launch, poll/loop in background priority for receive packets, and control send packet access to the socket using a mutex.
Bernard
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:***@Keystone-Software.com http://www.Keystone-Software.com
Loading...