Page 1 of 1

how to create a simple server using visual basic

Posted: Tue Mar 25, 2008 11:22 am
by thecobra
this is a tutoring of how to make a server that recive the packet from a client in visual basic 6.0

1.create a new project
Image

2.1 get Winsock from it componet

2.2 add winsock and

3.add listbox and

4.add two label
Image


5.view the form as code and wrigth this in it:


Code: [Select]
Private Sub Form_Load()
' set up the socket to listen on port 300
Winsock1.LocalPort = "300"
Winsock1.Listen
'it replace the label 1 with the server ip
label1.Caption = Winsock1.LocalIP
'it replace the label 2 with the server port used
label2.Caption = Winsock1.LocalPort

End Sub

Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
' reset the socket, and accept the new connection
Winsock.Close
Winsock.Accept RequestID
End Sub


Private Sub Winsock_DataArrival(ByVal BytesTotal As Long)
Dim strData As String
' get the data from the internal winsock buffer
Winsock.GetData strData
' show the user the data
List1.AddItem strData
End Sub

Private Sub Winsock_Close()
'if it lose conection it will restart the winsocket
Winsock.Close
Winsock.Listen
End Sub

It showed look something like this:

Image



6.now run the application it showed look soething like this:

Image

i hope u injoy it and learn how to make cool application with it
sorry if i mispell something but i was in a rush

Posted: Tue Jun 24, 2008 7:02 am
by SHAdmin
Well, that was a very good 'How To'.

Your account has been credited with 70 points for sharing it.

Posted: Thu Dec 18, 2008 7:49 pm
by thecobra
thanks, i dint thought you posted it up. soon i will show how to make a client for it and more cool stuff. maybe show some in java and in c ;)

Posted: Thu Aug 09, 2012 6:21 am
by miketyson
Hey it is very useful. thank you for sharing nice information.