|
-
Mar 23rd, 2003, 04:33 AM
#1
VB - Client/Server Example
VB Code:
'Client code
Dim str As String
Private Sub Command2_Click()
Winsock1.SendData "|MESSAGE|" & Text2.Text
End Sub
Private Sub Command1_Click()
Winsock1.Connect Text1.Text, "1001"
End Sub
'Server code
Dim str As String
Private Sub Form_Load()
Winsock1.LocalPort = 1001
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> closed Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData str
If InStr(1, str, "|MESSAGE|") <> 0 Then
message = Mid$(str, "10", Len(str))
Text1.Text = message
End If
End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 9th, 2010, 09:34 PM
#2
Re: VB - Client/Server Example
It will be helpful, if you provide some description...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jan 11th, 2010, 07:09 AM
#3
Hyperactive Member
Re: VB - Client/Server Example
wow, i understood what he did.
now i have to check if this connection method realley work.
i hope yesssssssssssssssss.
my current method (that i learn here), is to set the remote server like this
winsck.RemoteHost = Text1.Text
winsck.RemotePort = 1001
EDIT: i just checked this.
both methods seem to make the same task.
doesn't work for me when trying with 2 virtual machines.
hope it'll work on real machines.
Last edited by whatsup; Jan 11th, 2010 at 07:32 AM.
-
Jan 11th, 2010, 08:38 PM
#4
Re: VB - Client/Server Example
 Originally Posted by akhileshbc
It will be helpful, if you provide some description... 
The code sends a message as text from the client to the server then the server displays the message in a textbox.
 Originally Posted by whatsup
wow, i understood what he did.
now i have to check if this connection method realley work.
i hope yesssssssssssssssss.
my current method (that i learn here), is to set the remote server like this
winsck.RemoteHost = Text1.Text
winsck.RemotePort = 1001
EDIT: i just checked this.
both methods seem to make the same task.
doesn't work for me when trying with 2 virtual machines.
hope it'll work on real machines.
1. What you need is a winsock control named "Winsock1" for both projects.
2. Two textboxes and two command buttons for the client.
3. A textbox for the server.
4. Use the above code in the appropriate projects.
By the way this code is nearly 7 years old.
Last edited by Nightwalker83; Jan 11th, 2010 at 08:46 PM.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 13th, 2010, 02:28 AM
#5
Hyperactive Member
Re: VB - Client/Server Example
 Originally Posted by Nightwalker83
1. What you need is a winsock control named "Winsock1" for both projects.
2. Two textboxes and two command buttons for the client.
3. A textbox for the server.
4. Use the above code in the appropriate projects.
By the way this code is nearly 7 years old.
maybe you didn't understand (or i didn't).
I know and can send/recieve files when the sender and reciever on the same machine.
but when i tried to put the sender on virtual machine 1
and the reciever on virtual machine 2
it didn't work.
maybe because the both machines have the same external IP.
so i'll have to check this with 2 different computers that have different
external IP.
(unless someone tell me if it can be done on the same IP.)
-
Jan 13th, 2010, 02:40 AM
#6
Re: VB - Client/Server Example
 Originally Posted by whatsup
maybe you didn't understand (or i didn't).
I know and can send/recieve files when the sender and reciever on the same machine.
The description was actually in response to akhileshbc's post, I should have mentioned that.
but when i tried to put the sender on virtual machine 1
and the reciever on virtual machine 2
it didn't work.
maybe because the both machines have the same external IP.
so i'll have to check this with 2 different computers that have different
external IP.
(unless someone tell me if it can be done on the same IP.)
Last I tried it worked for me on the same machine (not virtual machine). Try using the local ip i.e 127.0.0.1 and see if that works. Unfortunately, I no longer have the source code on my computer and vb 6.0 is acting up from me on Vista.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|