Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to transfer a data between client application for both pc and android through internet.So i need one server.

From client side,i need to poll the server whether it has data from another client.
If it has,i need to connect to server to retrieve the data.

For this i planned to use sockets because i can able to transfer lot of data in a single connection.

First i planned to use PHP sockets,But PHP sockets allow only one request at a time.
So then i planned to use Java Custom Server Application with SSL Socket.

To setup the server,i'm going to get VPS and execute the Java application in that vps.

Is this best idea?
Posted
Updated 16-Feb-15 21:18pm
v3
Comments
Sergey Alexandrovich Kryukov 17-Feb-15 2:07am    
Can you ever stop asking about nothing?
Are you going to create a server for the sake of creating server? Yes, what you want to do is find, but it all depends on your goals you don't bother sharing with us. Can you please stop wasting your and our time for nothing? First of all, re-posts are considered as abuse.
—SA
cybersa 17-Feb-15 2:51am    
I already mentioned that

I have a client application for both pc and android.I need to connect this client app to sever for transferring of data between clients through internet.
Mohibur Rashid 17-Feb-15 3:06am    
First of all, if you don't have a server already, why do you have client for both pc and android? By the way, you are not being detained. PHP socket has nothing to do with you description. What you need is a server that will transmit data. I would suggest you(as you seems learning) you better start with HTTP server. PHP will process your data and reply to your pc and android application. And remember HTTP server don't send request to client by its own. Client would have to beg and then server will respond. And please be more constructive with your question. I would request you to follow Sergey Alexdrvich Kryukov's Suggestion.
cybersa 17-Feb-15 3:18am    
Ok.
I improved the question.
Mohibur Rashid 17-Feb-15 3:32am    
As I said, any http server will do. Install apache, install php, cause they are free and do your thing, your client will have to request to http port, php will process the rest.

1 solution

Please see my comments to the question.

Not only client per thread is too much, it is, at the same time, not enough. Server side needs at least two communication thread for two different purposes: one listens for new connection, another one sending/receiving data. Please see my past answers:
an amateur question in socket programming[^],
Multple clients from same port Number[^],
How Do I Get To Know If A A Tcp Connection Is Over[^].

Also, you mentioned "poll the server". Why polling the server "for any request"? The meaning of request is different; this is something which can be done at any time. But if you really need polling (to get to the moment of time when some activity is completed, typically), this is another bad idea. You need to understand that client-server model is a very bad, limiting model. Please see my past answer:Application 'dashboard' for website accounts[^].

Now, the bright side is: with sockets, you are not limited by the client-server. The server push mentioned in the post post referenced above can be easily implemented. For example, you can implement application-layer protocol implementing published-subscriber or its combination with client-server, or anything like that. Just note that you always implement some application-level protocol on top of the transport-layer protocol, even if you don't call it a protocol. So, it's better not to pretend you don't and do it explicitly. Naturally, this application-layer will be custom for a custom service (I would prefer call it "service", not "server" to avoid suggestive naming referring to pure client-server.) Please see:
http://en.wikipedia.org/wiki/Application_layer[^],
http://en.wikipedia.org/wiki/Transport_layer[^],
http://en.wikipedia.org/wiki/Transmission_Control_Protocol[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900