Solved

Open Socket via VBA

Posted on 2013-01-28
3
5,032 Views
Last Modified: 2013-01-30
Here's some code in VB.NET:

Dim port As Int32 = 9200
            Dim client As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient(server, port)
            Dim netStream As System.Net.Sockets.NetworkStream = client.GetStream()
            Dim charData As Char() = New Char() {}
            ReDim charData(data.Length)
            ' Translate the passed message into ASCII
            'Dim sb As StringBuilder = New StringBuilder()

            For i As Integer = 0 To data.Length - 1
                charData(i) = ChrW(data(i))
                'sb.Append(charData(i).ToString())
            Next
            'sb.Append("")
            data = System.Text.Encoding.ASCII.GetBytes(charData)
            netStream.Write(data, 0, data.Length)
            ' Close everything.
            netStream.Close()

Open in new window


I need similar functionality from within MS Access / VBA.

Essentially, I need to open a socket and send some data through it, then close the socket.

I'm trying to avoide 3rd party (paid) tools, if possible.

Thanks for your help.
0
Comment
Question by:Kaprice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 38830453
Here's an article describing how to use the WinSock control:

Create a Syslog Sender/Receiver Using the MS Winsock Control

The ActiveX control can be a bit hard to locate but that is explained as well.

/gustav
0
 

Author Closing Comment

by:Kaprice
ID: 38838542
Thanks. That's a good article.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 38838600
You are welcome!

/gustav
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question