1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.net; 18 19 import java.io.InputStream; 20 import java.io.OutputStream; 21 22 import com.badlogic.gdx.Net; 23 import com.badlogic.gdx.Net.Protocol; 24 import com.badlogic.gdx.utils.Disposable; 25 26 /** A client socket that talks to a server socket via some {@link Protocol}. See 27 * {@link Net#newClientSocket(Protocol, String, int, SocketHints)} and 28 * {@link Net#newServerSocket(Protocol, int, ServerSocketHints)}.</p> 29 * 30 * A socket has an {@link InputStream} used to send data to the other end of the connection, and an {@link OutputStream} to 31 * receive data from the other end of the connection.</p> 32 * 33 * A socket needs to be disposed if it is no longer used. Disposing also closes the connection. 34 * 35 * @author mzechner */ 36 public interface Socket extends Disposable { 37 /** @return whether the socket is connected */ isConnected()38 public boolean isConnected (); 39 40 /** @return the {@link InputStream} used to read data from the other end of the connection. */ getInputStream()41 public InputStream getInputStream (); 42 43 /** @return the {@link OutputStream} used to write data to the other end of the connection. */ getOutputStream()44 public OutputStream getOutputStream (); 45 46 /** @return the RemoteAddress of the Socket as String */ getRemoteAddress()47 public String getRemoteAddress (); 48 } 49