Solved

Sockets programming

Posted on 2006-06-21
17
212 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
  • 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
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.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Groovy problem when using SOAPUI : DispatchException occurred 7 58
tomcat administrtor 12 61
CSV file parsing thru Java 13 34
passing enum to a method 4 20
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

856 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