Link to home
Start Free TrialLog in
Avatar of more2chance
more2chance

asked on

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.
Avatar of more2chance
more2chance

ASKER

I am using VB6.0 Enterprise
Urgent!!
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
https://www.experts-exchange.com/questions/10303029/Client-and-Server-with-Winsock-in-LocalIP-too.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!
ASKER CERTIFIED SOLUTION
Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.