01 /*
02 * Created on Jul 3, 2004
03 *
04 * To change the template for this generated file go to
05 * Window - Preferences - Java - Code Generation - Code and Comments
06 */
07 package biz.xsoftware.examples.socket;
08
09 import java.io.IOException;
10 import java.net.Socket;
11 import java.nio.ByteBuffer;
12
13 /**
14 * The real implementation behind TCPSocket.
15 *
16 * @author Dean Hiller
17 */
18 public class TCPSocketImpl implements TCPSocket {
19
20 private Socket socket;
21 /**
22 * @showcode
23 */
24 public TCPSocketImpl(Socket s) {
25 socket = s;
26 }
27
28 /**
29 * @see biz.xsoftware.examples.socket.TCPSocket#read(java.nio.ByteBuffer)
30 * @showcode
31 */
32 public int read(ByteBuffer b) throws IOException {
33 return socket.getChannel().read(b);
34 }
35
36 /**
37 * @see biz.xsoftware.examples.socket.TCPSocket#write(java.nio.ByteBuffer)
38 * @showcode
39 */
40 public int write(ByteBuffer b) throws IOException {
41 return socket.getChannel().write(b);
42 }
43 }
|