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++ MT-multithreading and servers » Lost socket error (and how to get it)
Lost socket error (and how to get it) [message #40198] Tue, 02 July 2013 10:47 Go to previous message
koldo is currently online  koldo
Messages: 3361
Registered: August 2008
Senior Veteran
Hello all

When calling TcpSocket::Connect() the error code is lost. Take a look to actual function and comments:

bool TcpSocket::RawConnect(addrinfo *arp)
{
	if(!arp) {
		SetSockError("connect", -1, "not found");
		return false;
	}
	for(int pass = 0; pass < 2; pass++) {
		addrinfo *rp = arp;
		while(rp) {
			if(rp->ai_family == AF_INET == !pass && // Try to connect IPv4 in the first pass
			   Open(rp->ai_family, rp->ai_socktype, rp->ai_protocol)) {
				if(connect(socket, rp->ai_addr, (int)rp->ai_addrlen) == 0 ||
				   GetErrorCode() == SOCKERR(EINPROGRESS) || GetErrorCode() == SOCKERR(EWOULDBLOCK)
				) {
					mode = CONNECT;
					return true;
				}
				Close();		// Error is cleaned
			}
			rp = rp->ai_next;
		}
    }
	SetSockError("connect", -1, "failed");		// Here is not reported
	return false;
}

A possible solution to get the error could be:
- int errorCode
- errorCode = GetErrorCode() just before Close()
- Including TcpSocketErrorDesc(errorCode) in SetSockError();


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Need a working simple example of using sockets with GUI in U++
Next Topic: Communicate two PCs using http
Goto Forum:
  


Current Time: Thu May 09 16:23:13 CEST 2024

Total time taken to generate the page: 0.02301 seconds