Valhalla Legends Forums Archive | Visual Basic Programming | Winsock Help

AuthorMessageTime
FuZe
I'm using visual basic and I'm having problem with a fileshare program I'm trying to make.
winsock_connect() fires up even though the server side is still listening. Thats if I put this code under the cmdSend module:
[code]
If wsSend.State = sckClosed Then
wsSend.Connect txtAddress.Text, 5050
frmMain.Caption = "Connecting..."
cmdSend.Caption = "Cancel"
Do Until wsSend.State = sckConnected
DoEvents
Loop
End If
[/code]

If I don't put the do loop, then even though the server side has accepted the connection, the winsock_connect() never fires up.

Also, I was wondering about when winsock_error occurs. Sometimes that event occurs like when the connection was forcefully rejected, but other times, the event never occurs and the error goes to the local error handling code.

Any help woudl be appreciated. thx
July 23, 2003, 2:17 PM
Grok
[quote author=FuZe- link=board=5;threadid=2028;start=0#msg15754 date=1058969853]
I'm using visual basic and I'm having problem with a fileshare program I'm trying to make.
winsock_connect() fires up even though the server side is still listening. Thats if I put this code under the cmdSend module:
[code]
If wsSend.State = sckClosed Then
wsSend.Connect txtAddress.Text, 5050
frmMain.Caption = "Connecting..."
cmdSend.Caption = "Cancel"
Do Until wsSend.State = sckConnected
DoEvents
Loop
End If
[/code]

If I don't put the do loop, then even though the server side has accepted the connection, the winsock_connect() never fires up.

Also, I was wondering about when winsock_error occurs. Sometimes that event occurs like when the connection was forcefully rejected, but other times, the event never occurs and the error goes to the local error handling code.

Any help woudl be appreciated. thx
[/quote]

Get rid of the loop. The winsock control will raise the Connect event when the remote side has accepted the connection.

[code]Private Sub wsSend_Connect()
mConnected = True
frmMain.Caption = "Connected!"
cmdSend.Caption = "&Send"
cmdSend.Default = True
End Sub[/code]

HTH.
July 23, 2003, 10:00 PM
Camel
If you're trying to transfer files in VB, you might want to reconsider. It's fine if you're just trying to learn, but you're probably going to cap off at about 20k/sec.
July 24, 2003, 5:33 PM
FuZe
[quote author=Camel link=board=5;threadid=2028;start=0#msg15925 date=1059068038]
If you're trying to transfer files in VB, you might want to reconsider. It's fine if you're just trying to learn, but you're probably going to cap off at about 20k/sec.
[/quote]

how come?
August 4, 2003, 12:20 AM
Camel
[quote author=FuZe- link=board=5;threadid=2028;start=0#msg16947 date=1059956403]
[quote author=Camel link=board=5;threadid=2028;start=0#msg15925 date=1059068038]
If you're trying to transfer files in VB, you might want to reconsider. It's fine if you're just trying to learn, but you're probably going to cap off at about 20k/sec.
[/quote]

how come?
[/quote]

Mostly due to overhead. If you badly want to use VB, I would suggest writing the file-transfer portion with a custom DLL.
Here's an example of a program using VB to transfer files: http://www.xs.tech.nu/
August 11, 2003, 5:50 PM
TheMinistered
Thats funny, I can send files faster than 20k a second! Although I am not using the winsock ocx, but instead the winsock api.
August 11, 2003, 6:07 PM
Adron
CPU speed and not using the ocx are probably important factors...
August 11, 2003, 6:19 PM

Search