Argh!!!! Winsock


Thread Starter


I am trying to use Winsock to write an app to communicate from IP to IP using VB 6.

I start off by saying

Winsock1.Protocol = sckTCPProtocol

When I run the program it highlights sckTCPProtocol and says variable not defined. I think I must be missing a reference or something. Or
is there somewhere I have to define something else.

Have you added the Winsock control to your project? I tried out the code and it worked ok for me. If you haven't added the winsock control to your project - then right click in your controls bar on the left (default on the left) - then choose Components. You'll now get a windows with a list of all available components. Choose the one named MS Winsock or something Winsock. Mark the checkbox in front of this control name. Then choose OK or so to close the window. You will now see the Winsock control in your control bar. Double click on it in order to add it to your project.

I took this out of memory so there might be a few steps wrong. Here's a little sample code to establishe a connection from one of my little projects:

frmMain.sckMailComm.Protocol = sckTCPProtocol
If (frmMain.sckMailComm.State = sckConnected) Then
End If

strWantedAnswer = "220"
frmMain.sckMailComm.Connect frmMain.txtServerIP.Text, 25

blnTimeOut = False
tmrTimeOut.Interval = 5000
tmrTimeOut.Enabled = True
Do Until ((frmMain.sckMailComm.State = sckConnected) Or (blnTimeOut =
tmrTimeOut.Enabled = False

If (blnTimeOut = True) Then
intJunk = MsgBox("No Connection Was Established", vbOKOnly +
vbInformation, "No Connection")
End If

If (frmMain.sckMailComm.State = sckConnected) Then
intJunk = MsgBox("Connected To SMTP-Server", vbOKOnly + vbInformation,
"Connection Info")
End If

Lynn A Linse

You may want to try out some of the free WinSock "front-ends" designed for easier VB use. I've had good luck with the "Socket Wrench" from
"": . It gives you a standard VB object which has properties, methods, events etc. They also have example applications.


Lynn A Linse, Senior Industrial Automation Apps Engineer
Lantronix, 15353 Barranca Parkway, Irvine CA 92618 (USA)
Mobile: (949)300-6337 Office (949)450-7272 Fax (949)453-7152
[email protected]

Jeff LeBlanc

You should have a module with all of the winsock definitions in it.

If you need one email me.