?
Solved

client-server communication

Posted on 2003-03-18
6
Medium Priority
?
223 Views
Last Modified: 2013-11-13
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
Comment
Question by:more2chance
[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
  • 3
  • 2
6 Comments
 

Author Comment

by:more2chance
ID: 8158035
I am using VB6.0 Enterprise
0
 

Author Comment

by:more2chance
ID: 8158073
Urgent!!
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 8158470
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 15

Accepted Solution

by:
JackOfPH earned 460 total points
ID: 8158518
just experiment with the winsock control gud luck!

:-)
JackOfPH
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8158736
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
 

Author Comment

by:more2chance
ID: 8259759
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

777 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