Solved

Client/server through TCP/IP

Posted on 1998-07-23
1
279 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

726 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