com.rabbitmq.client.impl
Class SocketFrameHandler

java.lang.Object
  extended by com.rabbitmq.client.impl.SocketFrameHandler
All Implemented Interfaces:
FrameHandler

public class SocketFrameHandler
extends java.lang.Object
implements FrameHandler

A socket-based frame handler.


Field Summary
 java.io.DataInputStream _inputStream
          Socket's inputstream - data from the broker
 java.io.DataOutputStream _outputStream
          Socket's outputstream - data to the broker
 java.net.Socket _socket
          The underlying socket
 
Constructor Summary
SocketFrameHandler(java.net.Socket socket)
           
 
Method Summary
 void close()
          Close the underlying data connection (complaint not permitted).
 java.net.InetAddress getAddress()
          Retrieve address of peer.
 int getPort()
          Retrieve port number of peer.
 int getTimeout()
          Get the underlying socket's timeout in milliseconds.
 Frame readFrame()
          Read a Frame from the underlying socket.
 void sendHeader()
          Write a connection header to the underlying socket, containing the protocol version supported by this code, kickstarting the AMQP protocol version negotiation process.
 void sendHeader(int major, int minor)
          Write a 0-8-style connection header to the underlying socket, containing the specified version information, kickstarting the AMQP protocol version negotiation process.
 void sendHeader(int major, int minor, int revision)
          Write a 0-9-1-style connection header to the underlying socket, containing the specified version information, kickstarting the AMQP protocol version negotiation process.
 void setTimeout(int timeoutMs)
          Set the underlying socket's read timeout in milliseconds, if applicable.
 void writeFrame(Frame frame)
          Write a Frame to the underlying socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_socket

public final java.net.Socket _socket
The underlying socket


_inputStream

public final java.io.DataInputStream _inputStream
Socket's inputstream - data from the broker


_outputStream

public final java.io.DataOutputStream _outputStream
Socket's outputstream - data to the broker

Constructor Detail

SocketFrameHandler

public SocketFrameHandler(java.net.Socket socket)
                   throws java.io.IOException
Parameters:
socket - the socket to use
Throws:
java.io.IOException
Method Detail

getAddress

public java.net.InetAddress getAddress()
Description copied from interface: FrameHandler
Retrieve address of peer.

Specified by:
getAddress in interface FrameHandler

getPort

public int getPort()
Description copied from interface: FrameHandler
Retrieve port number of peer.

Specified by:
getPort in interface FrameHandler

setTimeout

public void setTimeout(int timeoutMs)
                throws java.net.SocketException
Description copied from interface: FrameHandler
Set the underlying socket's read timeout in milliseconds, if applicable.

Specified by:
setTimeout in interface FrameHandler
Parameters:
timeoutMs - The timeout in milliseconds
Throws:
java.net.SocketException

getTimeout

public int getTimeout()
               throws java.net.SocketException
Description copied from interface: FrameHandler
Get the underlying socket's timeout in milliseconds.

Specified by:
getTimeout in interface FrameHandler
Returns:
The timeout in milliseconds
Throws:
java.net.SocketException

sendHeader

public void sendHeader(int major,
                       int minor)
                throws java.io.IOException
Write a 0-8-style connection header to the underlying socket, containing the specified version information, kickstarting the AMQP protocol version negotiation process.

Parameters:
major - major protocol version number
minor - minor protocol version number
Throws:
java.io.IOException - if there is a problem accessing the connection
See Also:
FrameHandler.sendHeader()

sendHeader

public void sendHeader(int major,
                       int minor,
                       int revision)
                throws java.io.IOException
Write a 0-9-1-style connection header to the underlying socket, containing the specified version information, kickstarting the AMQP protocol version negotiation process.

Parameters:
major - major protocol version number
minor - minor protocol version number
revision - protocol revision number
Throws:
java.io.IOException - if there is a problem accessing the connection
See Also:
FrameHandler.sendHeader()

sendHeader

public void sendHeader()
                throws java.io.IOException
Write a connection header to the underlying socket, containing the protocol version supported by this code, kickstarting the AMQP protocol version negotiation process.

Specified by:
sendHeader in interface FrameHandler
Throws:
java.io.IOException - if there is a problem accessing the connection
See Also:
FrameHandler.sendHeader()

readFrame

public Frame readFrame()
                throws java.io.IOException
Read a Frame from the underlying socket.

Specified by:
readFrame in interface FrameHandler
Returns:
an incoming Frame, or null if there is none
Throws:
java.io.IOException - if there is a problem accessing the connection
See Also:
FrameHandler.readFrame()

writeFrame

public void writeFrame(Frame frame)
                throws java.io.IOException
Write a Frame to the underlying socket.

Specified by:
writeFrame in interface FrameHandler
Parameters:
frame - an incoming Frame, or null if there is none
Throws:
java.io.IOException - if there is a problem accessing the connection
See Also:
FrameHandler.writeFrame(Frame frame)

close

public void close()
Description copied from interface: FrameHandler
Close the underlying data connection (complaint not permitted).

Specified by:
close in interface FrameHandler