Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

can not get detail socket connect error

Moderators: kris

Posted: 11/17/07 11:13:43

the tango socket connect function not report detail error message, only poor "Unable to connect socket:".

So I write my connect function, but I found the Address, IPV4Address all hide the name(), nameLen() member, So I can't call it :(

Any method to do this work without hacking tango source ?

Author Message

Posted: 11/17/07 20:23:59

the class members are protected, but there are methods to access the name and port as a char[] :: IPv4Address.toUtf8() for example ?

Also, the bland error-message means that there was no available system-error, which is surprising. Which O/S are you using?

Posted: 11/18/07 03:54:46

sorry, my mistake, the error message is not produced by tango lib, but my workmate's code.

But I still want the connec result code, so I can check errno, base on the errcode, such as ECONNREFUSED (host is alive, but service is not), ENETUNREACH to determine the further selection.

Now I derived a MyIPv4Address from IPv4Address, public expose the name, nameLen, and use it with stdc connect. I don't like to write code parse string from Address to get back ip/port.

Posted: 11/18/07 06:22:38

So you need the error code available from within the Exception? The problem is that they are not consistent across O/S. If you'd be happy to create a set of error-code enums for Win32, linux, and Darwin, then that would be a big help ... we could add that to Socket (or somewhere) and make that enum/error-code available from the exception.

Posted: 11/18/07 12:56:53

So you need the error code available from within the Exception?

Indeed I like a connect not throw exception, so I can direct read the errno.

The problem is that they are not consistent across O/S. If you'd be happy to create a set of error-code enums for Win32, linux, and Darwin, then that would be a big help ... we could add that to Socket (or somewhere) and make that enum/error-code available from the exception.

en, this, posix like systems nearly all have very like error codes, such as ECONNREFUSED/ENETUNREACH, so, it would not be a problem :)

Posted: 11/18/07 13:06:39

kris wrote:

If you'd be happy to create a set of error-code enums for Win32, linux, and Darwin, then that would be a big help ... }}}

I'd like to give some contribution to tango libary, but maybe lately, these two/three months I'm busy on serval projects, even not time to train the new workmate :(

I'm using tango at a real project(under linux), today the upgraded tango version give me mysticism ld error at an previous ok project, said tango.text.convert.layout(a very long name, you know) declared in discardable section :(

at last, I get rid the regex import from ddbi file, the error disppear. very strange.

Perhaps this is relative to the bug in dmd obj file generation ( Gregor said ). It nearly make me mad .

Posted: 11/18/07 15:40:24

redsea wrote:

I'm using tango at a real project(under linux), today the upgraded tango version give me mysticism ld error at an previous ok project, said tango.text.convert.layout(a very long name, you know) declared in discardable section :(

at last, I get rid the regex import from ddbi file, the error disppear. very strange.

Perhaps this is relative to the bug in dmd obj file generation ( Gregor said ). It nearly make me mad .

I think Gregor is correct, and is most likely related to bugzilla entry #1508, see also our page for toolchain issues.

Posted: 11/19/07 17:38:22

redsea wrote:

So you need the error code available from within the Exception?

Indeed I like a connect not throw exception, so I can direct read the errno.

Would this work?

import tango.sys.Common;

try
{
  // execute code which throws error due to errno
}
catch(Exception e)
{
  int errno = SysError.lastCode;
  // deal with errno
}

Of course, the error numbers are OS-specific, so it isn't exactly portable.