News:

  • August 29, 2026, 01:52:08 PM

Login with username, password and session length

Author Topic: Is anyone kind enough to post a basic TCP sample project?  (Read 12594 times)

piscis

  • Newbie
  • *
  • Posts: 3
Is anyone kind enough to post a basic TCP sample project?
« on: November 06, 2013, 11:00:06 AM »
I'm using a Do-More H2-DM1E and will like to know how to open a TCP connection, receive the expected data and close the connection once done.

I will like to be able to received a four digit number and store it in an empty PLC variable.

For testing purposes I will be using this Android App:
https://play.google.com/store/apps/details?id=com.aviramido.udpserver

I will appreciate if anyone is able to help.

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Is anyone kind enough to post a basic TCP sample project?
« Reply #1 on: November 06, 2013, 01:21:44 PM »
Check the DoMore example program section on this forum. There is an example web server I posted there. If you want the DoMore to be the client, then let me know, and I will try to post a sample for you.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Is anyone kind enough to post a basic TCP sample project?
« Reply #2 on: November 06, 2013, 02:16:49 PM »
If the Do-more is the one initiating the connection:
1. Create a TCP Client device.
2. Use OPENTCP instruction to open TCP connection to your partner.
3. Use STREAMOUT to send data; use STREAMIN to get data.
4. Use CLOSE to close the TCP Client device (which will close the TCP connection).

If the Do-more is the one receiving the connection:
1. Create TCP Server device.
2. Use TCPLISTEN instruction to listen and respond to the partner's TCP connection request.
3. Use STREAMIN to receive data; use STREAMOUT to send data.
4. If the Do-more is to terminate the connection, then, again, use CLOSE. If the partner is going to close the connection, then there is nothing to do except go back up and use TCPLISTEN for the next time he wants to connect.

Use the Help file for these instructions to understand their use and their parameters.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

piscis

  • Newbie
  • *
  • Posts: 3
Re: Is anyone kind enough to post a basic TCP sample project?
« Reply #3 on: November 07, 2013, 08:14:09 AM »
plcnut:

The answer is YES the Android App will always be the one initiating the communication. The Do-More will just sit still and wait for the App to send a 4 digits value like for example(3499) once this is received and store into a variable the connection can be closed.

This connection section will repeat approximately once every two minutes with the 4 digits value constantly changing.

I will appreciated if you could provide me with an example program including the suggested port number to use?

Do-More PLC IP Address: 192.168.10.75
Android Tablet IP Address: 192.168.10.33
Router IP Address: 192.168.10.1

piscis

  • Newbie
  • *
  • Posts: 3
Re: Is anyone kind enough to post a basic TCP sample project?
« Reply #4 on: November 08, 2013, 01:00:41 PM »
plcnut:

Were you able to work on the example you mentioned?

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Is anyone kind enough to post a basic TCP sample project?
« Reply #5 on: November 08, 2013, 01:35:34 PM »
No I have not. I am happy to help but am covered up right now.
There is also another TCP sample located here: http://forum.hosteng.com/index.php/board,20.0.html
Look them over and do some experimenting. You might surprise yourself with what you can learn :)
I will post another sample for you when I get a chance...
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Is anyone kind enough to post a basic TCP sample project?
« Reply #6 on: November 08, 2013, 03:04:11 PM »
Were you able to work on the example you mentioned?

Plcnut is just another user like yourself. He took the time to study the instruction set and developed the webserver posted in the examples section. I suggest you get that code and look over it. Between that example and the information Greg posted to this thread, you should have everything you need to develop it yourself. It is quite simple.

Generally, folks around here are very willing to help others that are willing to help themselves, but they probably won't do it for you.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO