KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonathan > apis > protocols > ip > IpConnection


1 /***
2  * Jonathan: an Open Distributed Processing Environment
3  * Copyright (C) 1999 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 2.0
20  *
21  * Contact: jonathan@objectweb.org
22  *
23  * Author: Bruno Dumant
24  */

25
26
27 package org.objectweb.jonathan.apis.protocols.ip;
28
29 import org.objectweb.jonathan.apis.resources.Chunk;
30 import java.io.IOException JavaDoc;
31
32 /**
33  * A IpConnection represents a communication resource. It encapsulates a socket.
34  * A connection may always be related to a given session, i.e., a communication
35  * channel.
36  */

37 public interface IpConnection {
38    
39    /**
40     * Returns the session attached to this connection.
41     * @return the session attached to this connection.
42     */

43    IpSession getSession();
44
45    /**
46     * Attaches a new session to this connection.
47     * @param session the session to be attached to the target connection.
48     */

49    void setSession(IpSession session);
50
51    void receive(Chunk chunk,int sz) throws IOException JavaDoc;
52
53    int available() throws IOException JavaDoc;
54       
55    void emit(Chunk chunk) throws IOException JavaDoc;
56
57    /**
58     * Returns the port number of the underlying socket.
59     * @return the port number of the underlying socket.
60     */

61    int getPort();
62
63    /**
64     * Returns the host name of the underlying socket.
65     * @return the host name of the underlying socket.
66     */

67    String JavaDoc getHostName();
68
69    /**
70     * Releases this connection. This is to indicate to the connection manager that
71     * this connection is no longer used.
72     */

73    void release();
74
75    /**
76     * Deletes this connection, removing it from the connection manager, and
77     * closing the socket. This method should not be used a a socket user unless
78     * a problem occurs on the connection, like an exception when trying to read
79     * or to write data.
80     */

81    void delete();
82 }
83
Popular Tags