Hyper Terminal Wannabe

I need to send a command in a similar method of that of hyperterminal, using an Ethernet connection.

When I send a Command, such as #Sq1 which is a sensor query, I also get a response. I need to be able to read this also for further use in my  VB program.

Please note that is needs to be via ethernet, not Comm port.

Also note that this input and reading of data needs to be done in source code, not input by the user during run time.

I am no expert so please explain what you are saying well.

Thanks,
   Crono15M

Crono15MAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Crono15MAuthor Commented:
Edited text of question.
0
mcriderCommented:
You're going to have to open a connection using winsock.  This involves adding the winsock control to your program.

You can do this by right-clicking the toolbar and selecting "Components...". Then select winsock from the list.

You will need to know the IP address and port number to connect to.


There is an example of using the winsock control in the help file...

Cheers!
0
Crono15MAuthor Commented:
Thanks, I do know the IP and the DataPort, and I have used WinSock to grab data before, but I have never actually sent a command over a connection.
If anyone has some source code to do it, that would be greatly appreciated.

Just say the command I want to send is #Pq 2

Thanks,
   Crono15M
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
After you are connected, you want to do:

   winsock1.SendData "#Pq 2"+VbCrLf

Cheers!
0
Crono15MAuthor Commented:
For some reason this still does not work. The error has something to do with an improper connection status.

I know my connection is established because I am getting data from the source.

Do you need to put the code in a certain subroutine?

0
mcriderCommented:
You can't use the SendData method until the socket state is "connected".

You can either put your SendData command in the Winsock1_Connect subroutine, or set up a do loop waiting for the socket to be connected, like this:

do
   select case winnsock1.state
      case sckConnected
           exit do
      case sckClosed
           'SOCKET CLOSED,CLEANUP AND GET OUT
           exit do
   end select
   doevents      
loop


Cheers!

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.