Professional Documents
Culture Documents
Tutorial Winsock
Tutorial Winsock
Page 1 of 8
Designing
Part:-
Private Declare
Function SendMessage Lib
"user32" Alias "SendMessageA" (ByVal
hwnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, lParam As
Any) As
Long
Private Declare
Function ReleaseCapture Lib
"user32" () As Long
Private Sub
cmdConnect_Click()
On Error Resume
Next
Winsock1.Connect txtIP.Text, "1412" 'Just remember this Port Number Should be Same on which
our Server is Listening
End Sub
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 2 of 8
Private Sub
cmdSend_Click()
On Error Resume
Next
txtSend.Text = ""
txtSend.SetFocus
End Sub
Private Sub
Form_MouseDown(Button As Integer,
Shift As Integer, X As Single, Y As
Single)
ReleaseCapture
End Sub
Private Sub
Label1_Click()
On Error Resume
Next
DoEvents
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 3 of 8
Unload Me
End Sub
Private Sub
Winsock1_DataArrival(ByVal
bytesTotal As Long)
On Error Resume
Next
Winsock1.GetData str
lstMessages.AddItem str
End Sub
Private Declare
Function SendMessage Lib
"user32" Alias "SendMessageA" (ByVal
hwnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, lParam As
Any) As
Long
Private Declare
Function ReleaseCapture Lib
"user32" () As Long
Private Sub
cmdSend_Click()
On Error Resume
Next
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 4 of 8
txtSend.Text = ""
txtSend.SetFocus
End Sub
Private Sub
Form_Load()
On Error Resume
Next
If Not
App.PrevInstance = True Then
Winsock1.Listen
End If
End Sub
ReleaseCapture
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 5 of 8
End Sub
Private Sub
Label1_Click()
On Error Resume
Next
DoEvents
'Now Unload it
Unload Me
End Sub
Private Sub
Winsock1_ConnectionRequest(ByVal
requestID As Long)
On Error Resume
Next
If Winsock1.State
<> sckClosed Then
Winsock1.Close
Winsock1.Accept requestID
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 6 of 8
End Sub
Private Sub
Winsock1_DataArrival(ByVal
bytesTotal As Long)
On Error Resume
Next
Winsock1.GetData str
lstMessages.AddItem str
End Sub
Email:- keral82@keral.com
FAQ
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 7 of 8
Q. What is sckClosed?---(By
Jack)
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012
Tutorial For Winsock Control(Updated Now also Includes FAQ) by Keral.C.Patel. Page 8 of 8
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48418&lng... 29/4/2012