|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.clackrouter.component.base.ClackComponent
net.clackrouter.application.TCPSocket
public class TCPSocket
Implementation of a TCP Socket for use by Clack applications.
Note: public methods exist both from application side interaction and for use of the TCPSocket ClackComponent within a ClackGraph.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.clackrouter.component.base.ClackComponent |
|---|
ClackComponent.Waiter |
| Field Summary | |
|---|---|
static int |
NUM_PORTS
|
static int |
PORT_NET_IN
Port to receive incoming packets from the TCP/IP stack components |
static int |
PORT_NET_OUT
Port to send outgoing packets to the TCP/IP stack components |
| Fields inherited from class net.clackrouter.component.base.ClackComponent |
|---|
componentCell, m_has_error, m_log, m_name, m_num_ports, m_packetcount_in, m_packetcount_out, m_ports, mListeners, mRouter, pendingError, SIGNAL_ERROR_LEN_MSEC, UNIQUE_COUNT, view |
| Constructor Summary | |
|---|---|
TCPSocket(TCB t,
Router router,
java.lang.String name)
|
|
| Method Summary | |
|---|---|
TCPSocket |
accept()
Returns a client socket once an incoming client connection has been received. |
void |
bind()
Default bind behavior selects a random port in the range between 1024 and 2024 and binds to the first listed interface on the router (often eth0) |
void |
bind(java.net.InetAddress local_address,
int local_port)
Binds the socket to a specified address and port. |
void |
close()
Closes this end of the socket connection, meaning no more data can be sent. |
void |
connect(java.net.InetAddress remote_address,
int remote_port)
Create a client connection to a remote host. |
ClackApplication |
getCurrentApplication()
the application using this TCPSocket |
TCB |
getTCB()
The transmission control block (TCB) associated with this socket |
void |
listen()
Puts the socket into the LISTENING state, ready to receive incoming connections as a server. |
void |
poll()
Callback to be called once per router-processing loop. |
java.nio.ByteBuffer |
recv(int max_size,
long msec_timeout)
Read in data from this socket. |
int |
send(java.nio.ByteBuffer buf_out)
Sends a buffer of data |
void |
setCurrentApplication(ClackApplication app)
Set the Clack application that is the parent of this application (used internally) |
protected void |
setupPorts(int numports)
Allocates an array of ClackPort objects to be used by this component |
| Methods inherited from class net.clackrouter.component.base.ClackComponent |
|---|
acceptPacket, createCopy, createInputPullPort, createInputPushPort, createOutputPullPort, createOutputPushPort, error, fireListeners, getColor, getComponentCell, getHierarchicalView, getLog, getName, getNumPorts, getPacketCountIn, getPacketCountOut, getPendingError, getPort, getPropertiesView, getRouter, getSerializableProperties, getTime, getTypeName, getUniqueCount, getView, handlePullRequest, hasError, initializeProperties, isHierarchical, isModifying, log, notifyAlarm, registerListener, sendOutPort, setAlarm, setComponentCell, setName, setPendingError, setView, showErrorDialog, signalError, try_repaint, unregisterListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PORT_NET_OUT
public static final int PORT_NET_IN
public static final int NUM_PORTS
| Constructor Detail |
|---|
public TCPSocket(TCB t,
Router router,
java.lang.String name)
| Method Detail |
|---|
protected void setupPorts(int numports)
ClackComponent
setupPorts in class ClackComponentnumports - the number of ports to createpublic void poll()
Checks if the application has closed this socket, and if all data has been sent notifies the socket to send a FIN
poll in class ClackComponent
public void bind()
throws java.lang.Exception
java.lang.Exception
public void bind(java.net.InetAddress local_address,
int local_port)
throws java.lang.Exception
At this time, no restrictions are placed on what addresses or ports may be bound to.
local_address - address to bind as sourcelocal_port - port to bind as source
java.lang.Exception
public void listen()
throws java.lang.Exception
java.lang.Exception
public void connect(java.net.InetAddress remote_address,
int remote_port)
throws java.lang.Exception
remote_address - remote destination addressremote_port - remote destination port
java.lang.Exception
public java.nio.ByteBuffer recv(int max_size,
long msec_timeout)
max_size - largest amount of data to be readmsec_timeout - millisecs to wait before returning an empty buffer
public TCPSocket accept()
This call loops until a client connection is recieved, which it returns. This is effectively a blocking socket.
public int send(java.nio.ByteBuffer buf_out)
throws java.lang.Exception
java.lang.Exceptionpublic void close()
public void setCurrentApplication(ClackApplication app)
public ClackApplication getCurrentApplication()
public TCB getTCB()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||