• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

client-server communication

I am building a client-server application with VB6.0 Enterprise. How do I pass data between the client module and the server module which are both running simultaneously. I have heard about dll's but I don't know how to use them either.

thanx for yo attention.
0
more2chance
Asked:
more2chance
  • 3
  • 2
1 Solution
 
more2chanceAuthor Commented:
I am using VB6.0 Enterprise
0
 
more2chanceAuthor Commented:
Urgent!!
0
 
JackOfPHCommented:
don't know about the dll but you can use winsock control to send data to other computer here is a simple code and some links :

****links****
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=3099
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10303029.html

***here is a cut from the links i gave you!*****

TCP Connection Basics
When creating an application that uses the TCP protocol, you must first decide if your application will be a server or a client. Creating a server means that your application will "listen," on a designated port. When the client makes a connection request, the server can then accept the request and thereby complete the connection. Once the connection is complete, the client and server can freely communicate with each other.

The following steps create a rudimentary server:

To create a TCP server

Create a new Standard EXE project.


Change the name of the default form to frmServer.


Change the caption of the form to "TCP Server."


Draw a Winsock control on the form and change its name to tcpServer.


Add two TextBox controls to the form. Name the first txtSendData, and the second txtOutput.


Add the code below to the form.
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

The procedures above create a simple server application. However, to complete the scenario, you must also create a client application.

To create a TCP client

Add a new form to the project, and name it frmClient.


Change the caption of the form to TCP Client.


Add a Winsock control to the form and name it tcpClient.


Add two TextBox controls to frmClient. Name the first txtSend, and the second txtOutput.


Draw a CommandButton control on the form and name it cmdConnect.


Change the caption of the CommandButton control to Connect.


Add the code below to the form.
Important   Be sure to change the value of the RemoteHost property to the friendly name of your computer.

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

The code above creates a simple client-server application. To try the two together, run the project, and click Connect. Then type text into the txtSendData TextBox on either form, and the same text will appear in the txtOutput TextBox on the other form.

i hope it helps you with your problem! gud luck!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JackOfPHCommented:
just experiment with the winsock control gud luck!

:-)
JackOfPH
0
 
EDDYKTCommented:
Create a class on server and you can call


createobject("your server ID") from client.
Once you get then point, you should be able to communicate each other


Your server must be written as ActiveX EXE.
0
 
more2chanceAuthor Commented:
I woul like my application running on a remote machine to receive/send messages to the application running on the server. Can you help? I'm building a monitoring system for a computer centre.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now