Status & Roadmap
Authors & License
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
Error in Web Package example... for sockets [message #34765] Sun, 11 December 2011 21:04 Go to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member

http://www.ultimatepp.org/srcdoc$Web$ConnectionOriented$en-u s.html

the first example:
Socket my_sock;

int port=2000;

String host = "";

if( ClientSocket(my_sock, port, host) );


    my_sock.Write("hello world!");



I think the ; behind
if( ClientSocket(my_sock, port, host) );
is to much and I think you have to give host as second argument and port as third.
if( ClientSocket(my_sock, host, port) )

[Updated on: Mon, 12 December 2011 12:47]

Report message to a moderator

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 &...
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, "", 5024)) {
	    return "x";
	if(IO) s.Write(r + "\n\0");
	if(a==1 && IO){
    	String st = s.ReadUntil('\n');
	    return st;
	return "y";

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

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: Wed Feb 26 14:51:13 CET 2020

Total time taken to generate the page: 0.01145 seconds