com.leafdigital.net.api
Interface Network.Port

Enclosing interface:
Network

public static interface Network.Port

A listening port.


Method Summary
 java.net.Socket accept()
          Waits infinitely for a connection then returns it.
 java.net.Socket accept(int timeout)
          Waits for a connection then returns it, or throws SocketTimeoutException.
 void close()
          Closes the port, cancelling any in-progress accept calls
 java.net.InetAddress getPublicAddress()
           
 int getPublicPort()
           
 

Method Detail

accept

java.net.Socket accept()
                       throws java.io.IOException
Waits infinitely for a connection then returns it.

Returns:
Socket connection
Throws:
java.io.IOException

accept

java.net.Socket accept(int timeout)
                       throws java.io.IOException
Waits for a connection then returns it, or throws SocketTimeoutException.

Parameters:
timeout - Timeout in milliseconds
Returns:
Socket connection
Throws:
java.io.IOException

close

void close()
           throws java.io.IOException
Closes the port, cancelling any in-progress accept calls

Throws:
java.io.IOException - Any error

getPublicAddress

java.net.InetAddress getPublicAddress()
Returns:
Public IP address for receiving connections

getPublicPort

int getPublicPort()
Returns:
Public port number


Copyright © 2011 Samuel Marshall. All rights reserved.