Solved

Sockets programming

Posted on 2006-06-21
17
209 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
 
LVL 30

Expert Comment

by:mayankeagle
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:mayankeagle
mayankeagle 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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:mayankeagle
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:mayankeagle
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:mayankeagle
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:mayankeagle
ID: 16999540
Yes, you really shouldn't make the server connect to the client - it should be the other way round.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now