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

how to fix problem, cant call class

im trying to use the below call i made a class file clas1.vb pasted the below code
now im trying to make it work

1: how do i call the call im trying


and im getting an error of
Error      1      Value of type 'String' cannot be converted to '1-dimensional array of String'.      C:\Documents and Settings\Pern\My Documents\Visual Studio 2005\Projects\ircd stress\ircd stress\Form1.vb      34      39      ircd stress

2: how do i pass the host and message args if i can get this to work

' client.vb
' Simple socket client that sends a string to the server
' and reads the response.
' Mike Woodring
' http://staff.develop.com/woodring
Imports System
Imports System.Net.Sockets
Imports System.Threading
Imports System.Runtime.Serialization.Formatters.Binary

Namespace AsynchSockets
    Public Class Client
        ' Command line:
        '      client hostname string_to_send
        Public Shared Function Main(ByVal Args() As String) As Integer
            Dim HostName As String = "localhost"
            Dim Msg As String = "Hello, .NET sockets."

            If Args.Length >= 1 Then
                HostName = Args(0)
            End If

            If Args.Length >= 2 Then
                Msg = Args(1)
            End If

            Dim c As New Client(HostName)
            Return c._Main(Msg)

        End Function 'Main

        Sub New(ByVal HostName As String)
            Console.WriteLine("Connecting to {0}", HostName)
            tcpSocket = New TcpClient(HostName, 6667)
            streamToServer = tcpSocket.GetStream()

        End Sub 'New

        Private Function GetCurrentThreadId() As Integer
            Return Thread.CurrentThread.GetHashCode()

        End Function 'GetCurrentThreadId

        Private Function _Main(ByVal Msg As String) As Integer
            Console.WriteLine("Sending {0} to server.", Msg)

            ' Send a string (newline terminated) to the server.
            Dim writer As New System.IO.StreamWriter(streamToServer)

            ' Read server response (up to a newline).
            Dim reader As New System.IO.StreamReader(streamToServer)
            Dim strResponse As String = reader.ReadLine()
            Console.WriteLine("Received: {0}", strResponse)

            Return 0

        End Function '_Main

        Private tcpSocket As TcpClient
        Private streamToServer As NetworkStream
    End Class 'Client
End Namespace
  • 3
1 Solution
Your trying to pass a string into an array.

Try : AsynchSockets.Client.Main(Nothing)

        Dim arr() As String = {"Host", "Message Here"}
sorry, should be: AsynchSockets.Client.Main(arr)
or simply AsynchSockets.Client.Main(Split("Host,message",","))
JohnnyAuthor Commented:
sorry nightman did refresh...other seams to work

altho the code to connect does not seam to work...grumble

a simple connection to irc and return the reply ....why is this so dang hard...grrrr (like the 5th code example ive tried no joy here)

thanks for the replies
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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