public class SctpSocket
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
SctpSocket.NotificationListener
Interface used to listen for SCTP notifications on specific socket.
|
Constructor and Description |
---|
SctpSocket(long ptr,
int localPort)
Creates new instance of SctpSocket.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept()
Accepts incoming SCTP connection.
|
void |
close()
Closes this socket.
|
void |
connect(int remotePort)
Initializes SCTP connection by sending INIT message.
|
static void |
debugSctpPacket(byte[] packet,
java.lang.String id) |
int |
getPort()
Returns SCTP port used by this socket.
|
void |
listen()
Makes SCTP socket passive.
|
void |
onConnIn(byte[] packet,
int offset,
int len)
Call this method to pass network packets received on the link.
|
(package private) void |
onSctpInboundPacket(byte[] data,
int sid,
int ssn,
int tsn,
long ppid,
int context,
int flags)
Notifies this SctpSocket about incoming data.
|
(package private) int |
onSctpOut(byte[] packet,
int tos,
int set_df)
Callback triggered by Sctp stack whenever it wants to send some network
packet.
|
int |
send(byte[] data,
boolean ordered,
int sid,
int ppid)
Sends given data on selected SCTP stream using given payload
protocol identifier.
|
int |
send(byte[] data,
int offset,
int len,
boolean ordered,
int sid,
int ppid)
Sends given data on selected SCTP stream using given payload
protocol identifier.
|
void |
setDataCallback(SctpDataCallback callback)
Sets the callback that will be fired when new data is received.
|
void |
setLink(NetworkLink link)
Sets the link that will be used to send network packets.
|
void |
setNotificationListener(SctpSocket.NotificationListener l)
Sets the listener that will be notified about SCTP event.
|
SctpSocket(long ptr, int localPort)
ptr
- native socket pointer.localPort
- local SCTP port on which this socket is bound.public static void debugSctpPacket(byte[] packet, java.lang.String id)
public boolean accept() throws java.io.IOException
java.io.IOException
public void close()
public void connect(int remotePort) throws java.io.IOException
remotePort
- remote SCTP port.java.io.IOException
- if this socket is closed or an error occurs
while trying to connect the socket.public int getPort()
public void listen() throws java.io.IOException
java.io.IOException
public void onConnIn(byte[] packet, int offset, int len) throws java.io.IOException
packet
- network packet received.offset
- the position in the packet buffer where actual data startslen
- length of packet data in the buffer.java.io.IOException
void onSctpInboundPacket(byte[] data, int sid, int ssn, int tsn, long ppid, int context, int flags)
data
- buffer holding received datasid
- stream idssn
- tsn
- ppid
- payload protocol identifiercontext
- flags
- int onSctpOut(byte[] packet, int tos, int set_df)
packet
- network packet buffer.tos
- type of service???set_df
- use IP don't fragment optionpublic int send(byte[] data, boolean ordered, int sid, int ppid) throws java.io.IOException
data
- the data to send.ordered
- should we care about message order ?sid
- SCTP stream identifierppid
- payload protocol identifierjava.io.IOException
public int send(byte[] data, int offset, int len, boolean ordered, int sid, int ppid) throws java.io.IOException
data
- the data to send.offset
- position of the data inside the bufferlen
- data lengthordered
- should we care about message order ?sid
- SCTP stream identifierppid
- payload protocol identifierjava.io.IOException
public void setDataCallback(SctpDataCallback callback)
callback
- the callback that will be fired when new data is
received.public void setLink(NetworkLink link)
link
- NetworkLink that will be used by this instance to
send network packets.public void setNotificationListener(SctpSocket.NotificationListener l)
l
- the SctpSocket.NotificationListener
to set.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.