Java Socket connected but no data is sent or received
I've created a simple socket server in Java which listens for connections
then establishes a socket with the client. Data is then read and written
over the socket.
The socket server is running in a Tomcat servlet container (Tomcat7) on an
Ubuntu server.
The problem I'm having is that when the client is on some wifi networks -
when a connection is made - the socket connects but no data is is received
from the client. The client automatically sends an initialization packet
when the connection is made, but the server is not receiving it.
This only happens on certain wifi networks - when the network is changed
then the connection works properly. I thought the issue might have to do
with the fact it's using a tcp6 socket - but after searching Google I
can't find any reason why that would matter?
netstat -tanp | grep 40
tcp6 0 0 :::4001 :::* LISTEN
13747/java
tcp6 0 0 :::4002 :::* LISTEN
13747/java
tcp6 0 0 :::4003 :::* LISTEN
13747/java
Example Code
// Listen for connections
SeverSocket m_cServerSocket = new ServerSocket(m_nPort);
Socket m_cSocket = m_cServerSocket.accept();
m_cServerSocket.close();
PrintWriter m_cSocketOut = new PrintWriter(m_cSocket.getOutputStream(),
true);
TBSockReader m_cSocketReader = new TBSockReader(m_cSocket,this);
// TBSockReader
String sReadLine;
BufferedReader in = new BufferedReader(new
InputStreamReader(m_isReadStream));
while ((sReadLine = in.readLine()) != null)
{
ManagerDataFromClient(sReadLine);
}
Also I don't think it's a firewall issue on the client side - as the
socket connects and stays connected until I close it. There is no firewall
on the server side.
Any help would be greatly appreciated!
Cheers
No comments:
Post a Comment