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 » U++ Library support » U++ Library : Other (not classified elsewhere) » Error in Web Package example... for sockets
Re: Error in Web Package example... for sockets [message #34986 is a reply to message #34765] Sat, 24 December 2011 03:15 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I think you are right that the ; should be removed and the IP is necessary.

Try one of the working examples.

I added a few things to one of mine:
bool IO;
String snd(String r, int a){
	Socket s;
	if(!ClientSocket(s, "127.0.0.1", 5024)) {
	    return "x";
	}
	if(IO) s.Write(r + "\n\0");
	if(a==1 && IO){
    	String st = s.ReadUntil('\n');
	    return st;
	}
	return "y";
}
#endif

The bool IO can be checked or set. If there is no connection time is not wasted for a response, ie: just return "x" and if{...} accordingly.

If a==1 then a response is expected from the server otherwise "y" is returned, otherwise the server will waste time.

Also remember '\n' is the end. If you want to send several lines of data at once replace the '\n' between lines with another delimiter, then as above I use "\n\0" at the end.

More time is usually spent in error handling of possible errors and optimizing rather just writing code that will work (some of the time).

edit: I have made several very dumb mistakes but posting the code and the problem usually someone on the forum will pick up on it and respond, that has been a great help for my errors.

[Updated on: Sat, 24 December 2011 03:54]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: AESStream + OpenSSL installed + cannot open file 'out32\libeay32.lib'
Next Topic: LibX11 error & lock-up in debug mode with GridCtrl
Goto Forum:
  


Current Time: Tue May 13 11:52:07 CEST 2025

Total time taken to generate the page: 0.00457 seconds