Solved

Sockets programming

Posted on 2006-06-21
17
210 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: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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is the difference between "sudo su" and "su - root" 6 102
Java passing arguments (type error) 2 48
micro services spring boot application error 3 141
jar file executable 12 38
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

914 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

22 Experts available now in Live!

Get 1:1 Help Now