Solved

Sockets programming

Posted on 2006-06-21
17
214 Views
Last Modified: 2012-05-05


hi all

can anyone help me out here

I have to write a server-side application that gathers data from a database and then gives that data to a Client - the Client is a VB exe

At first i was going to do this as a server-side webservice and send the data to the VB Client's endpoint (the VB Client would act as webservice)

However, this is not possible because the VB client is distributed externally.

So have thought about programming sockets.  The server-side java code will send the data to the opened socket & port.  The VB exe Client listens on that socket & port to collect it

Is this a plausible solution?  What else could we think of doing?

Any help much appreciated
0
Comment
Question by:dalecon
[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
  • 6
  • 5
  • 3
  • +1
17 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 25 total points
ID: 16950478
Sockets are indeed implemented generically in Java so that should work

>>the VB Client would act as webservice

Don't you mean as a web service client?

>>this is not possible because the VB client is distributed externally.

Not sure what you mean by that
0
 

Author Comment

by:dalecon
ID: 16950543




I was originally going to write a server-side webservice that the VB Client would access asyncronously.  So server-side would send the data to the Client's endpoint  - the Client would act as a Client web service, because server-side will be calling it when it has data to send

I was told by the person doing the VB part that it isn't possible for the Client to act as a webservice because the exe is distibuted externally (to the public) and for a Client - side web service to work would mean running a local web server - can't install a local web server on users PC's



then decded to think about sockets and whether that would work
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16950554
The VB client would still have to create a Socket - will that always be possible?
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 30

Expert Comment

by:Mayank S
ID: 16950626
You can't change the VB code, can you? If not, then you want it to be the client and the Java code to be the server, right? You generally don't talk from the server side to the client side but its the other way round so developing the VB side as a web-service does not make sense if it has to be the client (otherwise it becomes the server). Is the VB client coded in a way so as to call any socket server? If so, all you need is a server at the Java end this way:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21757720.html#16084277
0
 

Author Comment

by:dalecon
ID: 16950991

thanks for the link - i'll take a look
0
 

Author Comment

by:dalecon
ID: 16951139


the vb code and javacode haven't been developed yet - this is a new project




0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 25 total points
ID: 16951277
Then you can create the Java server the way I told you and you can create the VB client separately to open a socket to it.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16951411
Personally, since the VB client is going to have to create a network connection to a server, i'm not sure why you wouldn't want to do this as a webservice, which would be more generic and reusable
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16951474
The awe of a web-server....

Are you proposing the VB thing to be a web-service? Then its like the server itself, right? Not the client. And deploying it at various client locations means all those systems should have a web-server. Is the VB thing supposed to be a simple UI application for the user?
0
 

Author Comment

by:dalecon
ID: 16951590



if i create a java server-side webservice with methods that gather data from the database, when it's ready i then want to give it to the VB client

If the Client invokes my webservice, it has to wait for the server-side stuff to finish before it can carry on.

What I want to do is get the server-side data ready (this will be in the form of XML, using JDOM) then 'push' it to the Client.

So i need a way to tell the Client the data is ready so it can grab it and use it.  How?  

My thought, when the data is ready I open a socket and post my data / response.  Can i post data within a socket?  

The VB Client creates a soket and checks if there's anything there e.g. on a hourly basis


thanks for your help






0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16951626
>> Can i post data within a socket?  

Sure. Look at the socket examples:

http://www.javaalmanac.com/egs/java.net/pkg.html
0
 

Author Comment

by:dalecon
ID: 16951787


Do you use/know of Avast anti virus?  Every now and again you get a pop-up saying there's a new version available.  

This must check the version you have installed on your PC, check with server-side code what is the latest version and display the pop-up if the version you have is an older version, do you know how they do this?



i'll post my xml data to a socket, the vb client can keep looking at the data to see if there's anything there

0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16951886
It can be done in various ways. They can connect periodically to the server and check, then close the connection - for example.
0
 
LVL 4

Expert Comment

by:astorer
ID: 16992204
Most sensible people out there have firewalls on their PCs or networks.  

Most default configurations will not allow your server to connect to the client - it doesn't allow incoming connections.  Will your users be able to setup their firewall to allow this connection?

If not, that means the client must initiate the connection to your server.  Which means you need to use a port that is open in most firewals - port 80.  But using port 80 for anything other than web services is frowned upon.  So, doesn't that lead you back to web services ?

Your client will periodically connect to the server on port 80 to call the "haveYouGotAnythingForMe()" Web Service.  The server can then return the information to the client.  

Another benefit is that your server does not have to worry about what to do if the client is not running.  How can the server retry later?

Andrew
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16999540
Yes, you really shouldn't make the server connect to the client - it should be the other way round.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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.

689 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