how to create a simple server using visual basic

Write your "How To" regarding anything you are comfortable with and you feel it will help the forum members.

NOTE :: All threads started here will appear only after the approval from Administrator
Post Reply
thecobra
Posts: 196
Joined: Tue Mar 11, 2008 11:30 am

how to create a simple server using visual basic

Post by thecobra » Tue Mar 25, 2008 11:22 am

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



SHAdmin
Posts: 2049
Joined: Sat Dec 18, 2004 11:28 am

Post by SHAdmin » Tue Jun 24, 2008 7:02 am

Well, that was a very good 'How To'.

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

thecobra
Posts: 196
Joined: Tue Mar 11, 2008 11:30 am

Post by thecobra » Thu Dec 18, 2008 7:49 pm

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 ;)

miketyson
Posts: 19
Joined: Wed Aug 08, 2012 12:05 pm

Post by miketyson » Thu Aug 09, 2012 6:21 am

Hey it is very useful. thank you for sharing nice information.

Post Reply