This content has been marked as final. Show 8 replies
show some of your sending code. you don't need to be setting any of these flags in your application. you just need to use sockets correctly and it will all work out on the wire.
1 person found this helpful
The network people says that there are packets sent without the PUSH flag by the application.Very likely. There isn't an API for setting the PUSH flag in Java, so it won't be set unless the TCP stack sets it.
they say all data should contain the PUSH flag.The network people are mistaken. The PUSH flag is an option, and in practice it makes little or no difference to TCP processing. Show them the RFC you quoted from. Tell them that Java has never set the PUSH flag, and yet Java has been sending enormous TCP streams all over the world for over sixteen years
Thanks for your input. Supposing, I need to change the TCP stack option, is there any possiblity of changing this either at system level etc.,?. i.e using any system level settings for Windows/Linux?.
Thanks for your reply, below is my code consolidated snippet.
Socket socket = new Socket(host, port);
OutputStream output = new BufferedOutputStream(socket.getOutputStream());
ByteArrayInputStream byteArray = new ByteArrayInputStream(bytes); // Note : bytes -- Byte array which is holding the huge volume of data.
byte data = new byte[BYTES_PER_ARRAY];
int len = -1;
while((len = byteArray.read(data, off, BYTES_PER_ARRAY)) != -1)
When write operation is happening, in the middle it is disconnected with the exception java.net.SocketException:, But ther is no network disconnection. I dont know how to attach the documents here, If so, I can send you the wireshark tarce routes and some screenshots about the transmitted packets.
well, for one thing, that bit of code can be consolidated to:
also, what exactly is the socketexception that is thrown?
Socket socket = new Socket(host, port); socket.setTcpNoDelay(true); OutputStream output = socket.getOutputStream(); output.write(bytes); output.flush();
Supposing, I need to change the TCP stack optionYou don't. The RFC alone should have convinced you of that, also the complete absence of any Java API.
This line of enquiry is a complete waste of time.
Supposing, instead, you tell us what the actual problem is, rather than pursuing some else's incorrect diagnosis & solution.
in the middle it is disconnected with the exception java.net.SocketException:, But ther is no network disconnection.Now you're just contradicting yourself. Either there is a network disconnect or there isn't. If you got a SocketException, there was a disconnect (unless it was a SocketTimeoutException, which only happens during reading, so that isn't it). Apparently the peer has closed the connection while you were still writing to it. That could be either because you shouldn't be writing at all, i.e. an application protocol mis-implementation between server and client, or maybe the peer has just given up for some reason, for example an upload is too large.
I repeat. This has nothing whatsoever to do with the PUSH flag. Anybody who tells you different doesn't know what he is talking about, and should be studiously ignored, and avoided in future.
Thank you for the detailed explanation.
There's a lesson to be learned here. You had Java code and a Java exception, so you should at least have posted all that in the first place. You got led off on a wild goose chase by your network people, which can happen, but you should have started from the beginning here, with your network people's comments as extra information.