Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Client/server through TCP/IP

Posted on 1998-07-23
1
Medium Priority
?
292 Views
Last Modified: 2013-11-13
VB5 enterprise edition comes with a sample client/server project, that displays
"Hello Visual Basic Users" when a button is clicked at the client.
How do I make this application work when the server is on a remote machine, and
all I know about it is it's IP address?
0
Comment
Question by:chekhov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
seahpc earned 800 total points
ID: 1466572
you need to use the Win Socket control .
Attach is a simple code
you will need some buttons and textboxes and winsocket for it
'****************************
' Server / Remote Machine Codes
' TcpServer = Socket

Private Sub Form_Load()
      ' Set the LocalPort property to an integer.
      ' Then invoke the Listen method.
      tcpServer.LocalPort = 1001
      tcpServer.Listen
      frmClient.Show ' Show the client form.
End Sub

Private Sub tcpServer_ConnectionRequest _
(ByVal requestID As Long)
      ' Check if the control's State is closed. If not,
      ' close the connection before accepting the new
      ' connection.
      If tcpServer.State <> sckClosed Then _
      tcpServer.Close
      ' Accept the request with the requestID
      ' parameter.
      tcpServer.Accept requestID
End Sub



Private Sub txtSendData_Change()
      ' The TextBox control named txtSendData
      ' contains the data to be sent. Whenever the user
      ' types into the  textbox, the  string is sent
      ' using the SendData method.
      tcpServer.SendData txtSendData.Text
End Sub

Private Sub tcpServer_DataArrival _
(ByVal bytesTotal As Long)
      ' Declare a variable for the incoming data.
      ' Invoke the GetData method and set the Text
      ' property of a TextBox named txtOutput to
      ' the data.
      Dim strData As String
      tcpServer.GetData strData
      txtOutput.Text = strData
End Sub

'******************************
' Client code

Private Sub Form_Load()
      ' The name of the Winsock control is tcpClient.
      ' Note: to specify a remote host, you can use
      ' either the IP address (ex: "121.111.1.1") or
      ' the computer's "friendly" name, as shown here.
      tcpClient.RemoteHost = "RemoteComputerName"
      tcpClient.RemotePort = 1001
End Sub

Private Sub cmdConnect_Click()
      ' Invoke the Connect method to initiate a
      ' connection.
      tcpClient.Connect
End Sub

Private Sub txtSendData_Change()
      tcpClient.SendData txtSend.Text
End Sub


Private Sub tcpClient_DataArrival _
(ByVal bytesTotal As Long)
      Dim strData As String
      tcpClient.GetData strData
      txtOutput.Text = strData
End Sub

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question