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

Sockets programming



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
dalecon
Asked:
dalecon
  • 6
  • 5
  • 3
  • +1
2 Solutions
 
CEHJCommented:
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
 
daleconAuthor Commented:




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
 
CEHJCommented:
The VB client would still have to create a Socket - will that always be possible?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
daleconAuthor Commented:

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


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




0
 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
CEHJCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
daleconAuthor Commented:



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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> Can i post data within a socket?  

Sure. Look at the socket examples:

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


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
 
Mayank SAssociate Director - Product EngineeringCommented:
It can be done in various ways. They can connect periodically to the server and check, then close the connection - for example.
0
 
astorerCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
Yes, you really shouldn't make the server connect to the client - it should be the other way round.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now