|
-
Feb 9th, 2010, 09:44 AM
#1
Thread Starter
Member
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.
-
Feb 9th, 2010, 09:48 AM
#2
Lively Member
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.
-
Feb 9th, 2010, 12:44 PM
#3
Thread Starter
Member
Re: Address in use, Winsock
Okay right now it seems to be working, thank you.
-
Feb 10th, 2010, 05:21 AM
#4
Thread Starter
Member
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
it works fine. I can't understand it!
Please help me!
-
Feb 10th, 2010, 05:29 AM
#5
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,...
-
Feb 10th, 2010, 06:28 AM
#6
Thread Starter
Member
Re: Address in use, Winsock
-
Feb 10th, 2010, 06:40 AM
#7
Re: Address in use, Winsock
Whats in the variable? Have you stepped through?
-
Feb 10th, 2010, 06:56 AM
#8
Thread Starter
Member
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?
-
Feb 10th, 2010, 06:59 AM
#9
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.
-
Feb 10th, 2010, 09:12 AM
#10
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|