KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > NetworkSession


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.smb;
18
19 import java.io.IOException JavaDoc;
20 import java.net.UnknownHostException JavaDoc;
21
22 /**
23  * Network Session Interface
24  * <p>
25  * Base class for client network sessions.
26  */

27 public interface NetworkSession
28 {
29
30     /**
31      * Return the protocol name
32      *
33      * @return String
34      */

35     public String JavaDoc getProtocolName();
36
37     /**
38      * Open a connection to a remote host
39      *
40      * @param toName Host name/address being called
41      * @param fromName Local host name/address
42      * @param toAddr Optional address of the remote host
43      * @exception IOException
44      * @exception UnknownHostException
45      */

46     public void Open(String JavaDoc toName, String JavaDoc fromName, String JavaDoc toAddr) throws IOException JavaDoc, UnknownHostException JavaDoc;
47
48     /**
49      * Determine if the session is connected to a remote host
50      *
51      * @return boolean
52      */

53     public boolean isConnected();
54
55     /**
56      * Check if the network session has data available
57      *
58      * @return boolean
59      * @exception IOException
60      */

61     public boolean hasData() throws IOException JavaDoc;
62
63     /**
64      * Receive a data packet from the remote host.
65      *
66      * @param buf Byte buffer to receive the data into.
67      * @param tmo Receive timeout in milliseconds, or zero for no timeout
68      * @return Length of the received data.
69      * @exception java.io.IOException I/O error occurred.
70      */

71     public int Receive(byte[] buf, int tmo) throws IOException JavaDoc;
72
73     /**
74      * Send a data packet to the remote host.
75      *
76      * @param data Byte array containing the data to be sent.
77      * @param siz Length of the data to send.
78      * @return true if the data was sent successfully, else false.
79      * @exception java.io.IOException I/O error occurred.
80      */

81     public boolean Send(byte[] data, int siz) throws IOException JavaDoc;
82
83     /**
84      * Close the network session
85      *
86      * @exception java.io.IOException I/O error occurred
87      */

88     public void Close() throws IOException JavaDoc;
89 }
90
Popular Tags