Results 1 to 1 of 1
- 07-20-2012, 08:34 PM #1Member
- Join Date
- Jan 2011
- Rep Power
Transmitting files of 64k size through sockes fails.
I am developing an application that uses java sockets between a server and client apps. I need to send files of size 64k from client to server through these sockets. When I locally run all the system (both, server and client) everything goes ok, but when I run the server and client in different machines it fails.
I am using JSON to process the file content, so the thrown exception in server is: "net.sf.json.util.JSONTokener.syntaxError". However the problem is not JSON, is the size of the file. When I send files with a size lesser than 8k everything goes ok, but bigger sizes truncates the sent information, so it throws a JSONTokener.syntaxError when server tries to interpret truncated received information.
I am defining a socket buffer of 64k as following (I am using NIO API):
private static final int BUFFER _SIZE = (int)Math.pow(2, 16);
sc.socket().setReceiveBufferSize( BUFFER_SIZE );
sc.socket().setSendBufferSize( BUFFER_SIZE );
What do I need to do to enlarge the network package size when I run my system in a remote mode? Do you have any idea which is the problem?
Thank you very much in advance.
- By Jaeela in forum New To JavaReplies: 11Last Post: 12-04-2011, 11:10 PM
- By N4zroth in forum Advanced JavaReplies: 0Last Post: 12-17-2010, 02:53 PM
- By subrahmanyam.adapa in forum Advanced JavaReplies: 3Last Post: 01-26-2009, 02:19 PM
- By khajalid in forum NetworkingReplies: 2Last Post: 12-22-2008, 04:05 AM
- By pedaramanareddy in forum New To JavaReplies: 0Last Post: 01-03-2008, 03:39 PM