View Single Post
Old 06-13-2012, 05:05 PM   PM User | #10
TestingPHP
New Coder

 
Join Date: Jun 2012
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
TestingPHP is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
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[] argvthrows IOExceptionInterruptedException
    
{
        
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
    
}

TestingPHP is offline   Reply With Quote