• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 892
  • Last Modified:

How to communicate with a device (printer or something else) using an ethernet card>

I have an instrument that communicate with an ethernet card (using a JAVA applet).  I am not new in VB programming but my experience with Internet/Ethernet communication is limited. The instrument/device response when using IE to commands with the form of "http:\\IP Address\command?"  I would like to use VB to send this command using a http connection and direct the return to a file of some sort. I guess what I am missing is the right control to use! Any advice will be greatly appreciated. Also, please avoid giving answers in terms of link to other pages as I will not bother looking.
1 Solution

So the device you wish to communicate with has an IP address. And you send commands to it using http and then get whatever the response is and write it out.

You'll have to change it so that it writes to a file though

Try this from MSDN

Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Namespace Examples.System.Net
    Public Class WebRequestGetExample

        Public Shared Sub Main()
            ' Create a request for the URL.        
            Dim request As WebRequest = WebRequest.Create("http://ipaddress/command?")
            ' Get the response.
            Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
            ' Display the status.
            ' Get the stream containing content returned by the server.
            Dim dataStream As Stream = response.GetResponseStream()
            ' Open the stream using a StreamReader for easy access.
            Dim reader As New StreamReader(dataStream)
            ' Read the content.
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Display the content.
            ' Cleanup the streams and the response.
        End Sub 'Main
    End Class 'WebRequestGetExample
End Namespace

Hope this helps

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now