Hi,
If you want to do the whole thing in java
its very easy:
You'll need a serverapplication (in java)
that opens a serversocket for each client.
Something like this:
package com.tilt.maler.server;
import java.net.;
import java.io.;
class ImageConnection extends Thread {
Socket socket = null;
public boolean is_connected = false;
ServerSocket server = null;
ImageConnection (ServerSocket server_sock) {
server = server_sock;
}
boolean connected(){
return is_connected;
}
Socket get_socket(){
System.out.println("Returning the socket");
is_connected = false;
return socket;
}
public void run() {
while (true) {
is_connected = false;
if (!is_connected) //don't get another socket until this one taken
{
try {
System.out.println(server.getInetAddress().getLocalHost()+" listening on port: "+server.getLocalPort());
}
catch (Exception e){};
try{
socket = server.accept();
} catch(IOException e) {
System.out.println("Problem with server.accept in class ImageConnection:"+e);
}
System.out.println("Received new connection");
is_connected = true; //set that is connected
this.suspend();
}
}
}
}
Then you'll need to run a Thread in another class that runs in a loop and checks wether there is a connection ready at the ServerSocket.
If there is, instanciate another class
which deals with the reading process via a stream that is established via the returning socket of the Server.
Sounds confusing? Send me a mail for details.