Home » Community » Newbie corner » Socket - send multiple lines
Re: Socket - send multiple lines [message #29817 is a reply to message #29805] |
Fri, 19 November 2010 15:32   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
dolik.rce wrote on Thu, 18 November 2010 11:43 |
nlneilson wrote on Thu, 18 November 2010 10:15 | "for(;*q;q++)" is a bit new for me. for(;;) until break I understand. If I debugged some code it would become apparent.
|
|
I didn't use that approach. I was not able to read your post until I got back as I have no internet connection at my Ranch/Farm.
That is a major reason the upp installation should have more extensive help data or at least a separate download.
Quote: | I'm investigating how to get all the help into theIde at the moment but whether it's achievable or how long it will take to do I don't know yet.
Graeme
|
http://www.ultimatepp.org/forum/index.php?t=msg&th=5643& amp; amp; amp;start=0&
As I am not proficient with pointers the "*q" is also something I have not used very much. My programming with C++ was several years ago. Python and Java is what I have used lately which doesn't use pointers, or at least I don't recall using them in those languages.
I think upp is great, that is why I chose to use it. The way it wraps C++ so it is easier to program reminds me of Python which some consider a wrapper language.
In another upp app I did use pointer to a limited extent:
void split3(String ln, String& S1, String& S2, String& S3);
Maybe that is not even using a pointer.
I started by sending a String that included several lines, 4 at first, that included the \n after each line and that worked.
Then I tried to make a char buffer to match that.
When reading each char of what was to be sent after the last char of a line the \n had to be added. Apparently the in.Getline as far as the length with Ln.GetCount(); counts the \n but the char is not read as '10'(\n) but '0'(null).
With further debugging either of these will work:
if(j==cc) ch='\n; // j+=1 and cc=Ln.GetCount()
if(ch==0) ch='\n;
so my code has:
if(j==cc || ch==0) ch='\n;
In a previous post I mentioned the socket server and client did not have to be changed. When trying another app a glitch was found. The server was changed from reading a String with single line to reading a char buf with many lines. No big deal, just have to change some code.
I am pulling as much of my Java code out of the display app that is based on NASA WWJ and porting it to C++ in upp.
Each of the lines is a point: Latitude, Longitude, Altitude and ID. If the Lat or Lon is out of range of the display (or if the Alt not relevant) the line will be culled or omitted. This is faster in C++ than Java, less heap space problems and is compiled not interpreted at runtime. And C++ is much harder to decompile.
Neil
edit: Honza, looking over your example code:
else if(*q=='\n') esc.Cat("\\n");
As pointed out above the '\n' with Getline() and then reading each char the '\n' is changed to 0. It seems that may be a problem when reading lines from a file, or am I missing something?
[Updated on: Fri, 19 November 2010 17:27] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Jun 08 02:30:35 CEST 2025
Total time taken to generate the page: 0.04526 seconds
|