VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Winsock Very Handy Tips

by Skull Hacker (6 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This code shows all the handy tips of winsock
such as connect until connected if disconnected
close the conenction and a few more bits of winsock code !

Rate Winsock Very Handy Tips

Ok in your VB project if you are making any type of program eg. Trojan , Chat Program or what ever in your connect button make sure you have the following code.
If Winsock1.State = 0 Then
Winsock1.RemoteHost = Text1.Text
Winsock1.RemotePort = 1000
Winsock1.Connect
Do Until Winsock1.State = sckConnected
  DoEvents: DoEvents: DoEvents: DoEvents
Loop
End If
Ok lets look at If Winsock1.State = 0 Then
this tells winsock only to go ahead with the 
command if winsock isnt connected this way the
crappy all ready conencted error will not come 
up. 
now look at this bit of code
Do Until Winsock1.State = sckConnected
This tells winsock to keep trying to connect
until connected.
Now in a command button or what ever when you have a button sending some data always put this
code.
If Winsock1.State = 0 Then Label.Caption = "Not Connected"
strdata = "data"
If Winsock1.State = sckConnected Then
Winsock1.SendData strdata
End If
This tells winsock of the state is 0 it will
say you are not connected.
Now lets look at this code.
if winsock1.state = sckClosing then winsock1.close 
label.caption = "Disconnected."
That code should be put in form load it tells
winsock if it gets disconnected it will close
and tell a label its disconnected so this will 
prevent the gay error were if you get dissed you
can still connect again !
I hope you enjoyed these tips have fun winsock 
prgraming i find it very awsome !

Download this snippet    Add to My Saved Code

Winsock Very Handy Tips Comments

No comments have been posted about Winsock Very Handy Tips. Why not be the first to post a comment about Winsock Very Handy Tips.

Post your comment

Subject:
Message:
0/1000 characters