Package org.cybergarage.http
Class HTTPServer
- java.lang.Object
-
- org.cybergarage.http.HTTPServer
-
- All Implemented Interfaces:
Runnable
public class HTTPServer extends Object implements Runnable
This class identifies an HTTP over TCP server
The server must be initialized iether by theopen(InetAddress, int)or theopen(String, int)method.
Optionally a set ofHTTPRequestListenermay be set
The server then can be started or stopped by the methodstart()andstop()- Version:
- 1.8
- Author:
- Satoshi "skonno" Konno, Stefano "Kismet" Lenzi
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PORTstatic intDEFAULT_TIMEOUTDefault timeout connection for HTTP comunicationstatic StringNAMEprotected inttimeoutStore the current TCP timeout value The variable should be accessed by getter and setter methostatic StringVERSION
-
Constructor Summary
Constructors Constructor Description HTTPServer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Socketaccept()voidaddRequestListener(HTTPRequestListener listener)booleanclose()StringgetBindAddress()intgetBindPort()static StringgetName()ServerSocketgetServerSock()intgetTimeout()Get the current socket timeoutbooleanisOpened()booleanopen(String addr, int port)booleanopen(InetAddress addr, int port)voidperformRequestListener(HTTPRequest httpReq)voidremoveRequestListener(HTTPRequestListener listener)voidrun()voidsetTimeout(int timeout)Set the current socket timeoutbooleanstart()booleanstop()
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT
Default timeout connection for HTTP comunication- Since:
- 1.8
- See Also:
- Constant Field Values
-
timeout
protected int timeout
Store the current TCP timeout value The variable should be accessed by getter and setter metho
-
-
Method Detail
-
getName
public static String getName()
-
getServerSock
public ServerSocket getServerSock()
-
getBindAddress
public String getBindAddress()
-
getBindPort
public int getBindPort()
-
getTimeout
public int getTimeout()
Get the current socket timeout- Since:
- 1.8
-
setTimeout
public void setTimeout(int timeout)
Set the current socket timeout- Parameters:
timeout-- Since:
- 1.8
-
open
public boolean open(InetAddress addr, int port)
-
open
public boolean open(String addr, int port)
-
close
public boolean close()
-
accept
public Socket accept()
-
isOpened
public boolean isOpened()
-
addRequestListener
public void addRequestListener(HTTPRequestListener listener)
-
removeRequestListener
public void removeRequestListener(HTTPRequestListener listener)
-
performRequestListener
public void performRequestListener(HTTPRequest httpReq)
-
start
public boolean start()
-
stop
public boolean stop()
-
-