Results 1 to 10 of 10

Thread: Address in use, Winsock

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    57

    Address in use, Winsock

    Hello I am using Winsock control, but when I try to connect VB 6 says error: "Address in use". If I close my server app and try to run my program it doesn't give this error. Here is my simple code so far:

    Code:
    Private Sub Form_Load()
    ws.Close
    ws.LocalPort = 1007
    ws.Connect "192.168.1.11"
    End Sub
    I left all winsock control properties to default in designer

    Please Help Me!
    Thank you in advance.

  2. #2
    Lively Member agent_007's Avatar
    Join Date
    Jan 2010
    Posts
    93

    Re: Address in use, Winsock

    try this

    Code:
    Private Sub Form_Load()
    ws.Close
    ws.Connect "192.168.1.11",1007
    End Sub

    Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    57

    Re: Address in use, Winsock

    Okay right now it seems to be working, thank you.

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    57

    Re: Address in use, Winsock

    Right now it doesn't say address in use, but when I try to send a specific text, it says "Wrong protocol or connection state for the requested transaction ot request."
    Here is the code:
    Code:
    Private Sub Form_Load()
    Me.Icon = LoadResPicture(ReadINI("MainWindow", "Icon", "UI.ptf", "MAIN"), vbResIcon)
    ws.Close
    ws.Connect "192.168.1.11", 1007
    ws.SendData ReadINI("INISection", "FirstErrNotify", "comunication.ptf", "[ERRREP]!")
    When I substitute the ReadINI function, with a static text like this
    Code:
    ws.SendData "Test"
    it works fine. I can't understand it!

    Please help me!

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Address in use, Winsock

    Try reading the data (using readini) to a string variable, and then use that variable to send data.... (I am not sure about this, just a thought)...

    eg:
    Code:
    Private Sub Form_Load()
    Me.Icon = LoadResPicture(ReadINI("MainWindow", "Icon", "UI.ptf", "MAIN"), vbResIcon)
    ws.Close
    ws.Connect "192.168.1.11", 1007
    dim strTemp as string
    strTemp=ReadINI("INISection", "FirstErrNotify", "comunication.ptf", "[ERRREP]!")
    ws.SendData strTemp

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    57

    Re: Address in use, Winsock

    I tried that already

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Address in use, Winsock

    Whats in the variable? Have you stepped through?

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    57

    Re: Address in use, Winsock

    For the time being the ReadINI function returns this "Program Error!". If you want here is the code in ReadINI
    Code:
    Public Function ReadINI(riSection As String, riKey As String, riFile As String, riDefault As String) As String
        Dim sRiBuffer As String
        Dim sRiValue As String
        Dim sRiLong As String
        Dim INIFile As String
        INIFile = App.Path & "\" & riFile
        If Dir(INIFile) <> "" Then
            sRiBuffer = String(255, vbNull)
            sRiLong = GetPrivateProfileString(riSection, riKey, Chr(1), sRiBuffer, 255, INIFile)
            If Left$(sRiBuffer, 1) <> Chr(1) Then
                sRiValue = Left$(sRiBuffer, sRiLong)
                If sRiValue <> "" Then
                    ReadINI = sRiValue
                Else
                    ReadINI = riDefault
                End If
            Else
                ReadINI = riDefault
            End If
        Else
            ReadINI = riDefault
        End If
    End Function
    But I actually found that on the Internet.
    I guess that's what you meant by variable, pino?

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Address in use, Winsock

    Have you tried removing the explination mark - Might be a problem with that character. I cant see why but give it a try.

    If you say that ws.SendData "Test" - Works then you have a problem with you INI function you need to make sure that the value returned from this function is correct - Step through the program using break points.

  10. #10

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    57

    Re: Address in use, Winsock

    Actually I tried out also something else
    Code:
    ws.SendData InputBox("", "", ReadINI("INISection", "FirstErrNotify", "ui.ptf", "[ERRREP]!"))
    in this code I show an input box and set the text from ReadINI as default, when I run the program and click OK on the input box it works.

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