Results 1 to 11 of 11

Thread: More Data Help

  1. #1

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    More Data Help

    Ok this is client - server based using Winsock. Here is what I have.

    This is the client sending the data to server:

    VB Code:
    1. Private Sub Command5_Click()
    2. Dim msgee As String
    3. msgee = "GI"
    4. Winsock2.SendData msgee
    5.  
    6. Exit Sub
    7. End Sub

    This is the Server Receiving the data:

    VB Code:
    1. Private Sub winsock1_DataArrival _
    2. (ByVal bytesTotal As Long)
    3. Dim strData As String
    4. Winsock1.GetData strData
    5.  
    6.     If strData = "GI" Then
    7.     Dim info As String
    8.     info = "Test"
    9.     Winsock1.SendData info
    10.     Exit Sub
    11.     End If
    12.    
    13. End Sub

    This is the client receiving the data from the server:

    VB Code:
    1. Private Sub winsock1_DataArrival _
    2. (ByVal bytesTotal As Long)
    3. Dim strData As String
    4. Winsock1.GetData strData
    5. Text1.Text = strData
    6.  
    7. End Sub

    Well it looks good except it is not working. When I click the command button in the first code, it shoud send the data to the server. Then the server will recieve the data and check if it is "GI". If it is then, it will create a variable with the text "Test" in it, and send it back to the client. Then whatever the client recieves back from the server will be placed in text1.text. Except nothing appears. I have gone through about 3 times and can't figure out whats wrong. Probably something simple, but im not sure. Can anyone help?
    Last edited by Inuyasha1782; Jun 3rd, 2005 at 05:47 PM.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: More Data Help

    Don't use Winsock1.Close after sending, that closes the connection!


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: More Data Help

    oops should of seen that one, still not working though
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  4. #4

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: More Data Help

    Here is the whole thing if someone wants to look at it to see if something else interferes. This includes both client and server projects.
    Attached Files Attached Files
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: More Data Help

    You need to put some code into the Winsock2.DataArrival event to put the received string into Text1
    VB Code:
    1. Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    2. Dim strData As String
    3. Winsock2.GetData strData
    4. Debug.Print strData
    5. Text1 = strData
    6.  
    7. End Sub

  6. #6
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: More Data Help

    Also put
    VB Code:
    1. Option Explicit
    at the beginning of each module and you'll find another error

  7. #7

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: More Data Help

    Alright one more question thats related to this. How do I put what ever is in a text file into a variable so I can send it to the client and display it there. So it would go like this:
    1. The Client sends the trigger to the server
    2. The server reads the trigger, and then sets a variable to a text file say something like "C:\Test.txt"
    3. The variable is sent over to the the client, and the client displays the the text in the text document that was in the variable.

    Does anyone know how to do that?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: More Data Help

    You could use this

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Dim ff As Integer
    5.   Dim strBuff As String
    6.   Dim str() As String
    7.   ff = FreeFile
    8.   Open "c:\temp\todo.txt" For Input As #ff
    9.     strBuff = Input(LOF(ff), ff)
    10.   Close #ff
    11.   msgbox strBuff ' <--------------------------- TextFile is here
    12. End Sub

  9. #9

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: More Data Help

    Alright so if I were to recieve the data, and place it in another variable and then used something like Text1.text = "Variable the contents of the text file would be displayed?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: More Data Help

    Yes. It may contain multi lines, so set the property to multiline, or use a msgbox.

  11. #11

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: More Data Help

    One more thing. Some files are not really text files, but can be displayed as one using like Notepad. Would this way have the same effect? So like say I open a file thats a .dll. Windows automatically asks what I want to open this file in. I select Notepad and it displays to me the contents of the dll in code form. Will this way have the same result? Or mabye when I got it I could shell notepad to display the code for me?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


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