Go to Post I think these new rules are making the message coming from FIRST perfectly clear - engineering is about what happens between your ears, not what comes out of your deep pockets. - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 09-03-2012, 11:00
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: URGENT Sending data over tcp

Here are some things to check out:

1) Is RoboRealm flushing output at every int, or is getting buffered?

2) Why is "instream.read()" called 2x in your loop?

3) The field "Socket.datain" is being used to communicate between threads. For correct portable code this should be declared "volatile", or all reads and writes should be guarded by synchronized statements. This shouldn't actually matter for Java on the cRIO though.

4) There isn't any built-in Java-level input buffering on a Socket's input stream in this version of Java. That shouldn't result in a 10x slowdown though.

To test this you could try reading into a 4-byte array, and constructing an int from that

Code:
byte b[] = new byte[4];

while (true) {
    int len = instream.read(b, 0, b.length); // should check that len is 4, and buffer up until full, but in practice you should see 4 bytes...

    datain = (b[0] << 24) | ((b[1] & 0xFF) << 16) |((b[2] & 0xFF) << 8) | (b[1] & 0xFF);  // or reverse the byte order if necessary.
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:21.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi