Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Socket Communication 101
Re: Socket Communication 101 [message #39673 is a reply to message #39671] Tue, 16 April 2013 20:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nlneilson wrote on Tue, 16 April 2013 13:51

Thanks for the link, I saved that and also the document so it can be read off line.

Yes the data does get buffered but the difference was in my code.
Before it was like this:

getline
reformat
send

That was one packet.

getline
reformat
send

That was another packet.




Well, this is possible in case that your network is relatively faster than getline/reformat. See

http://en.wikipedia.org/wiki/Nagle%27s_algorithm

It still does not quite explain errors...

Mirek
Re: Socket Communication 101 [message #39676 is a reply to message #39673] Tue, 16 April 2013 22:43 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thanks for the link.

The socket is just 'sending' data from the Upp app to a Java app.
There is no internet connection necessary but I do have a 100 MB connection.

The errors were shown up in the Java display app.

Here are a few lines from a file I open in Upp
// SW corner 35.028940,-117.970440,804.4 from S20 35.028928,-117.970460
35.04361500,-117.96188300
c,35.036235,-117.961830,35.036335,-117.961730
		
c,35.043615,-117.961883,35.028850,-117.961610 // correct ?? N 1/4 corner
c,35.043617,-117.962056,35.028850,-117.961610 // old        N 1/4 corner
		
c,35.036291,-117.970649,35.036184,-117.952831
		
c,35.028940,-117.970440,35.028759,-117.952780
c,35.028759,-117.952780,35.043566,-117.952887
c,35.043663,-117.970880,35.043617,-117.962056
c,35.043617,-117.962056,35.043566,-117.952887
c,35.028940,-117.970440,35.043663,-117.970880 //W
//    Farm
c,35.036291,-117.970649,35.036235,-117.961830
c,35.036235,-117.961830,35.037156,-117.961853
c,35.037156,-117.961853,35.037189,-117.966238
c,35.037189,-117.966238,35.039954,-117.966357
c,35.039982,-117.970770,35.039954,-117.966357


Each line that starts with c, is a path with two points and the other lines are ignored. Sometimes survey data is represented degrees, minutes and seconds rather than decimal degrees so the data is 'formatted' to decimal degrees and checked for like a latitude greater than 90 degrees, etc..

Most survey data is E->W or N->S that I am using.
Sending the data as a packet for each line without an adequate Sleep time many of the paths are diagonal as the points are out of order. Using print statements shows the data is not in order also.

Putting all the data in one buffer and sending in one packet all the data is received and displayed correctly.

Using shared memory between C++ and Java may be faster but was more complicated so a socket is being used.

This is displayed correctly, the two diagonal lines near the bottom is intended.
http://www.nlneilson.com/wwposts/Survey-Paths.pnghttp://www.nlneilson.com/wwposts/Survey-Paths.png

The upper left is the Upp app.

This displays the errors:
http://www.nlneilson.com/wwposts/Survey-Paths-errors.png
http://www.nlneilson.com/wwposts/Survey-Paths-errors.png

[Updated on: Tue, 16 April 2013 23:31]

Report message to a moderator

Re: Socket Communication 101 [message #39679 is a reply to message #39676] Wed, 17 April 2013 08:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nlneilson wrote on Tue, 16 April 2013 16:43

Thanks for the link.

The socket is just 'sending' data from the Upp app to a Java app.



OK, that explains packets (time for packet to pass from socket to socket is very low, so none get buffered).

Quote:


The errors were shown up in the Java display app.



That is still very weird. Frankly, given nature of TCP/IP protocol and the fact that U++ side of things is quite primitive, I would start looking for bug(s) in Java app...

Mirek
Re: Socket Communication 101 [message #39831 is a reply to message #39679] Sun, 05 May 2013 02:45 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Yes the problems seem to be on the java end.

Data is received but apparently there is no positive method to keep the data in order. Each 'line' represents two points. For the points to get messed up so they are not consistent with the path that is supposed to be drawn gives the diagonal lines.

The transfer is very fast whether sent separately or as one buffer. The time taken by the java app to change the format if necessary, error handling and draw it while additional lines are actually being received into some unknown que.

C++ and Upp are very good and most problems end up being in java.
Previous Topic: ScatterCtrl / ScatterDraw - ShowLegend() problem and general Question
Next Topic: Spin + Text
Goto Forum:
  


Current Time: Thu Apr 25 23:26:30 CEST 2024

Total time taken to generate the page: 0.03301 seconds