Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java to VB Winsock control

 
carl jensen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use sockets to allow java to communicate to VB (winsock control). The messages are about 32,000 bytes.
The messages seem to be getting truncated at 8192 bytes. How do I read the whole message in?
Please help!

public NetWorkServer (Socket s) throws IOException {
socket = s;
in = socket.getInputStream();
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
start();
}
public void run()
{
try
{
int bytesAvailable = in.available();
while(bytesAvailable == 0) {
try {
sleep(20);
bytesAvailable = in.available();
}
catch(InterruptedException ie) {
}
}
char[] messageBytes = new char[bytesAvailable];
for (int i = 0; i < messageBytes.length; i++) {
messageBytes[i] = (char) in.read();
}
message = new String(messageBytes);


 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me like your apparent limit is packet size (8K) instead of trying to read all the bytes at once, read them in 8k at a time in a loop until the read(byte[] b, int start, int bytesToread) returns -1.
Hope this helps
 
carl jensen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! I'll give it a shot.
 
carl jensen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, but I guess I'm still not real sure how to do this. Right now, I'm reading bytes into with the following routine
Could you elaborate?
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something along the line of


Hope this helps
[This message has been edited by Carl Trusiak (edited December 06, 2000).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!