What is the difference between a port and a socket?
This was a question raised by one of the software engineers in my organisation. I’m interested in the broadest definition. 36 s 36
This was a question raised by one of the software engineers in my organisation. I’m interested in the broadest definition. 36 s 36
I have a Tomcat based web application. I am intermittently getting the following exception, Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:150) at java.net.SocketInputStream.read(SocketInputStream.java:121) at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:532) at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501) at org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:563) at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:124) at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:346) at org.apache.coyote.Request.doRead(Request.java:422) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290) at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:431) at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200) at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385) Unfortunately I don’t have access to … Read more
I am getting the following error trying to read from a socket. I’m doing a readInt() on that InputStream, and I am getting this error. Perusing the documentation this suggests that the client part of the connection closed the connection. In this scenario, I am the server. I have access to the client log files … Read more
As other people have pointed out, it is most likely related to another process using port 9999. On Windows, run the command: netstat -a -n | grep “LIST” And it should list anything there that’s hogging the port. Of course you’ll then have to go and manually kill those programs in Task Manager. If this still … Read more
Change your main to: public static void main(String[] args) { EchoServer echoServer = new EchoServer(); echoServer.listen(); } When you declare Object EchoServer0; you have a few mistakes. EchoServer0 is of type Object, therefore it doesn’t have the method listen(). You will also need to create an instance of it with new. Another problem, this is only regarding naming … Read more
There are 2 issues in your program: You use the port 80 which is part of the well-known ports or system ports (0 to 1023), so you need to launch your server with the admin rights or change it for 8080 for example. You forgot to call bw.newLine() after each bw.write(sendMessage) such that it waits for ever since on the other side you call br.readLine() which means that it … Read more
Unexpected end of file” implies that the remote server accepted and closed the connection without sending a response. It’s possible that the remote system is too busy to handle the request, or that there’s a network bug that randomly drops connections. It’s also possible there is a bug in the server: something in the request … Read more