|
-
Jul 23rd, 2003, 09:10 PM
#1
Thread Starter
New Member
WinSock Trouble
Ok I'm new to WinSock (I haven't programmed in VB in a while). I'm following this tutorial at: HERE
On the last page of it, it has all the code from in the tut:
' in your first program, we need to listen for a
' connection. Add the winsock control to your project by clicking on
' "Project"-->"Components". Scroll down to find the "Microsoft Winsock
' Control 6". Check the box, then click OK. Draw an control onto the form,
' call it "Winsock", and then paste this code into the form.
Private Sub Form_Load()
Winsock.LocalPort = 10101
Winsock.Listen
End Sub
Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
Winsock.Close
Winsock.Accept RequestID
End Sub
' in your Second program, we need to make an outgoing
' connection. So, follow the same procedure as above, and
' draw a Winsock onto the form, calling it "Winsock"
' Also, draw a command button on, and call it "cmdConnect"
Private Sub cmdConnect_Click()
Winsock.RemoteHost = "127.0.0.1"
Winsock.RemotePort = 10101
Winsock.Connect
End Sub
Private Sub Winsock_Connect()
MsgBox "Connected"
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, _
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _
ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error: " & Description
End Sub
' now run both programs within VB and press the command button.
' If all has gone to plan, you should get a msgbox saying "Connected"...
In the comments at the Top it says to go to Projects->Components and then scroll down to find Microsoft Winsock Contrl 6. But I can't find that. This is what I have:
Windows Form
Class
Module
Component Class
User Control
Data Form Wizard
DataSet
XML File
XML Schema
Code File
Custom Control
HTML Page
Inherited Form
Web Custom Control
inherited User Control
Windows Service
COM Class
Transactional Component
Test File
Frameset
XSLT File
Style Sheet
Installer Class
Bitmap File
Cursor File
Icon File
Assembly Resource File
Assembly Information File
Application Configuration File
JScript File
VBScript File
Windows Script Host
Do I have the Winsock Component and it's just a different name? Or is there a site I can Download it from?
Please Hurry with your replies!
Thanks
-
Jul 24th, 2003, 12:43 PM
#2
Hyperactive Member
.Net doesn't have the winsock component.
See the System.Net.Sockets entry in the .Net Framework SDK Documentation, which is included in your Visual Studio directory.
http://ms-help://MS.NETFrameworkSDK/...consockets.htm
-
Jul 25th, 2003, 04:01 AM
#3
Hyperactive Member
Try This
This is an example of how to implement the System.Sockets and System.Threading classes in VB.Net. It includes a multi-threaded server application as well as a client to demomstrate its use. This code is based off of a code example written in C# by Nick Ruisi so give credit where credit is due. Enjoy!
This file came from www.Planet-Source-Code.com
http://www.Planet-Source-Code.com/vb...=331&lngWId=10
-
Jul 27th, 2003, 08:27 PM
#4
Member
you might need to install VB6.0 with Winsock component first, coz on my machine i have both .net and vb60 installed and i am not sure if winsock is included in .net...
so, here is the steps:
1. goto form design
2. right click on toolbox and click on Add/Remove Items...
3. click on COM Components Tab
4. Select Windows Socket componet
-
Jul 27th, 2003, 08:39 PM
#5
Winsock isn't designed to be run in VB.NET , you do need to use the System.Net.Sockets way.
you can add a winsock , but it will give untold errors and wont send / receive data properly
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|