• Welcome to Valhalla Legends Archive.
 

Winsock Help

Started by FuZe, July 23, 2003, 09:17 AM

Previous topic - Next topic

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:

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


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

Grok

Quote from: FuZe- on July 23, 2003, 09:17 AM
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:

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


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

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

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


HTH.

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.

FuZe

Quote from: Camel on July 24, 2003, 12:33 PM
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.

how come?

Camel

Quote from: FuZe- on August 03, 2003, 07:20 PM
Quote from: Camel on July 24, 2003, 12:33 PM
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.

how come?

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/

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.

Adron

CPU speed and not using the ocx are probably important factors...