Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my sockets getInputStream return null?
    primarykey
    data
    text
    <p>Well I'm trying to make an application that will connect to a game's login database and connect to the chat server but whenever I try to use the Socket.getInputStream( ) function it throws an exception and doesn't give me anything... I'm not sure why it does this so I was wondering if any of you could help..</p> <p>I Connect like this:</p> <pre><code>public boolean Connect( String RemoteHostIP, int RemotePort ) { try { if( m_Socket != null ) { m_Socket.close( ); m_Socket = null; } m_Socket = new Socket( ); m_Host = RemoteHostIP; m_Port = RemotePort; m_Socket.connect( new InetSocketAddress( m_Host, m_Port ) ); System.out.println( " ~ Connected to: " + m_Socket.getInetAddress( ).getHostAddress( ) + ":" + m_Socket.getPort( ) ); } catch( SocketException Ex ) { m_Socket = null; System.err.println( "[SocketHelper::Connect SEN] " + Ex.getLocalizedMessage( ) ); return false; } catch( IOException Ex ) { m_Socket = null; System.err.println( "[SocketHelper::Connect IOE] " + Ex.getLocalizedMessage( ) ); return false; } return true; } </code></pre> <p>and then bind to my Input and Output like this:</p> <pre><code>public boolean Bind( ) { try { if( !m_Socket.isConnected( ) || m_Socket.isClosed( ) || !m_Socket.isBound( ) ) return false; if( m_Socket.getOutputStream( ) != null ) { m_Output = new ObjectOutputStream( m_Socket.getOutputStream( ) ); m_Output.flush( ); } if( m_Socket.getInputStream( ) != null ) { m_Input = new ObjectInputStream( m_Socket.getInputStream( ) ); } } catch( SocketException Ex ) { System.err.println( "[SocketHelper::Bind SEN] " + Ex.getLocalizedMessage( ) + " (" + m_Output + " | " + m_Input + ")" ); return false; } catch( IOException Ex ) { System.err.println( "[SocketHelper::Bind IOE] " + Ex.getLocalizedMessage( ) + " (" + m_Output + " | " + m_Input + ")" ); return false; } return true; } </code></pre> <p>and this is my output</p> <pre><code> ~ Connected to: 96.127.149.202:11031 Failed to Connect: Could not bind to socket [SocketHelper::Bind IOE] null (java.io.ObjectOutputStream@1202f4d | null) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload