Quote:
Originally Posted by Fou-Lu
Just use the example. All you need is to open the socket, then issue an .accept() within the while(true). Maybe sleep it for a couple of seconds. That's all you got to do. Technically you don't even need to accept if you don't plan on doing anything with it:
PHP Code:
public static void main(String[] argv) throws IOException, InterruptedException
{
ServerSocket welcomeSocket = new ServerSocket(43594);
while (true)
{
Thread.sleep(2000);
System.out.println("Nothing to do; take'n a nap.");
}
}
That's it.
|
Eh, I'm very new to Java
Why isn't this working?
PHP Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package port.listen;
/**
*
* @author TestingPHP
*/
class PortListen {
java.net.Socket.Serversocket welcomeSocket = new Serversocket(43594);
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}