?
Solved

Client/server through TCP/IP

Posted on 1998-07-23
1
Medium Priority
?
282 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

770 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