29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

}<br />

}<br />

catch(IOException ex)<br />

{<br />

Debugger.debug(getClass(), 2,<br />

"Could not close server connection on IP "<br />

+ serverIp + " : " + port);<br />

}<br />

protected void closeClientConnection()<br />

{<br />

try<br />

{<br />

clientIn.close();<br />

clientOut.close();<br />

clientSocket.close();<br />

Debugger.debug(getClass(), 2, "Client disconnected on port " + port);<br />

}<br />

catch(IOException ex)<br />

{<br />

Debugger.debug(getClass(), 2,<br />

"Could not close client connection on IP "<br />

+ clientIp + " : " + port);<br />

}<br />

}<br />

10.1.6.b AbstractNonBlokingProxy<br />

package <strong>Spam</strong>Cash.Client.Proxy;<br />

import java.util.*;<br />

import java.net.*;<br />

import java.nio.channels.*;<br />

import <strong>Spam</strong>Cash.Client.Control;<br />

import <strong>Spam</strong>Cash.Utilities.*;<br />

import <strong>Spam</strong>Cash.Utilities.Debugger;<br />

public abstract class AbstractNonBlockingProxy extends Thread<br />

{<br />

private boolean running = true;<br />

private static Class className;<br />

private int idCounter = 1;<br />

private volatile SocketChannel keyChannel;<br />

private volatile SelectionKey key;<br />

private Vector connections;<br />

private int maxConnections;<br />

protected Control control;<br />

protected int port;<br />

public AbstractNonBlockingProxy(Control control, int port,int maxConnections) throws<br />

Exception<br />

{<br />

this.control = control;<br />

this.port = port;<br />

this.maxConnections = maxConnections;<br />

}<br />

this.className = getClass();<br />

connections = new Vector();<br />

public void run()<br />

{<br />

273

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!