Results 1 to 4 of 4

Thread: VB 2010 Winsock Client/Server

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    15

    VB 2010 Winsock Client/Server

    Hello, all. This is my first post in here. I am currently learning how to program in VB and am using sample code to make a VB Winsock client and server. I beleive the sample code was from VB 6.0.

    I am getting an error with it though. Here is the code for the client:

    Code:
    Imports MSWinsockLib
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Data
    
    Public Class Form1
    
        Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
            sockMain.RemoteHost = txtHost.Text
            sockMain.RemotePort = txtPort.Text
            sockMain.Connect()
        End Sub
    
        Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click
            sockMain.SendData(txtSend.Text)
        End Sub
        Private Sub winsck_DataArrival(ByVal bytesTotal As Long)
            Dim strData As String
            sockMain.GetData(strData, vbString) ' <----ERROR HERE!!!!!!
            txtStatus.Text = txtStatus.Text & _
                strData & vbCrLf
        End Sub
    End Class
    Error:

    Overload resolution failed because no accessible 'GetData' accepts this number of arguments.

    I am getting the exact same error in the exact same place in the server aswell. I have tried removing the vbString, but it comes up with a warning and the program doesn't function like it should.

    I am programming this in Visual Basic 2010 Express. Any help is appreciated! Thansk!

    Cory

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: VB 2010 Winsock Client/Server

    If you're using VB.NET then the first thing you should do is stop using VB6 controls. The .NET Framework has multiple classes in the System.Net.Sockets namespace that provide an implementation of Windows Sockets. If you're using .NET then you should use .NET. For an example of the .NET classes in action, follow the CodeBank link in my signature and check out my Asynchronous TCP thread.

  3. #3
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Re: VB 2010 Winsock Client/Server

    you have too many arguments in the getdata variable, try les. or try to program arround it

  4. #4
    New Member
    Join Date
    Mar 2011
    Posts
    2

    Re: VB 2010 Winsock Client/Server

    I know this is an old thread but the way to get DataArrival is :

    Code:
    Private Sub AxWinsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles AxWinsock1.DataArrival
                Dim strData As Object = vbNullString
                AxWinsock1.GetData(strData , vbString, e.bytesTotal)
                        txtStatus.Text = txtStatus.Text & _
                strData & vbCrLf
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width