Results 1 to 4 of 4

Thread: Help with code

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    122

    Help with code

    Iam trying send command to the server to respond after the conenction is made.

    Private sub Send_Click()

    tcpclient.connect
    Sleep(1000)
    txtsend.Text = "some.txt"
    tcpClient.Senddata txtsend.text & Chr$(10) ---- error here
    end sub

    this code gives me an error in the send data command as wrong protocol or connection state for the requested transaction.

    need help

  2. #2
    Addicted Member Luke K's Avatar
    Join Date
    Jun 2004
    Location
    Perth, Australia
    Posts
    183

    Re: Help with code

    From the code you have given, the most likely cause of the error is that the winsock control is not connected. Make sure to check to see if the connection is open before you send any data

    VB Code:
    1. If tcpClient.State = sckConnected Then 'Now Send Data

    Before you connect, make sure you have the hosts ip/dns correct and make sure you have set what ports the control is to listen and send data on.
    Artificial Intelligence At War! - The best game of its genre
    Program your own robot and watch it fight in 3d!
    Droidarena 3

    If I have been useful, please Rate My Post

    Support FireFox -
    Microsoft Visual Studio .NET Professional 2003
    Microsoft Visual Studio 6, Enterprise Edition
    Microsoft Windows XP Professional, Service Pack 2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    122

    Re: Help with code

    iam able to connect to the remote server and then when i sent it didnt show any response.

    anyone help me with this

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    122

    Re: Help with code

    I worked till this and iam able to send first string command to server and how can i send the second command after I got response from server, as iam getting error.Here is the code iam working on.

    Private Sub Command1_Click()
    If Winsock1.State <> sckClosed Then
    Winsock1.Close
    End If
    Winsock1.Connect "0.0.0.0", 1234
    End Sub

    Private Sub Winsock1_Connect()
    Winsock1.SendData "easy.txt" & Chr$(10)
    List1.AddItem "Sent to Server: easy.txt"


    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Winsock1.GetData a$, vbString
    List1.AddItem "Received from server: " + a$
    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