|
Dear readers,
My first blogpost because blogs are known for problems and such.
I have started programming in Java years ago, but now i have to revisit the Runtime after a long periode of C-sharp and C++ programming.
I have to build a Server who can handle multiple clients, and the client. I tried to build a single-connection-server/client, but both applications wait or sleep for the other side to react.
I hope anyone can help me with this. I have googled for tuts, but i can't seem to get the picture.
tl:dr gimme the source server/client-model java-code or help to create it myself.
|
fun! Sadly I'm of no use I've never touched server programming.
|
depends on how scalable it must be: http://mina.apache.org/
also simple client/server examples should be everywhere around the net.
|
|
Thank you all.. but i need to write the code for a server/client model in java programming. Not a server for files or mysql/php.
|
|
imo mina is overkill. Just go with a simple socket and serversocket implementation.
1 - Create a ServerSocket and bind it to a port number. 2 - Poll on the port. Polling is fine for single threads but if you need this to scale for a lot of connections, you will need java.nio and use selectors along with ServerSocketChannel. 3 - The client will probably use the Socket class and connect to your server. Use it's InputStream and OutputStream to receive and send messages.
|
|
|
|