16858 " |
16860 " |
16859 ! ! |
16861 ! ! |
16860 |
16862 |
16861 !Win32OperatingSystem::Win32SocketHandle class methodsFor:'queries'! |
16863 !Win32OperatingSystem::Win32SocketHandle class methodsFor:'queries'! |
16862 |
16864 |
16863 getAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags |
16865 getAddressInfo:hostNameArg serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags |
16864 "answer an Array of socket addresses for serviceName on hostName |
16866 "answer an Array of socket addresses for serviceName on hostName |
16865 Domain, type, protocol may be nil or specify a hint for the socket |
16867 Domain, type, protocol may be nil or specify a hint for the socket |
16866 addresses to be returned." |
16868 addresses to be returned." |
16867 |
16869 |
16868 |error errorString result domain type proto serviceName port| |
16870 |error errorString result domain type proto hostName serviceName port| |
16869 |
16871 |
16870 domain := OperatingSystem domainCodeOf:domainArg. |
16872 domain := OperatingSystem domainCodeOf:domainArg. |
16871 type := OperatingSystem socketTypeCodeOf:typeArg. |
16873 type := OperatingSystem socketTypeCodeOf:typeArg. |
16872 proto := self protocolCodeOf:protoArg. |
16874 proto := self protocolCodeOf:protoArg. |
16873 serviceNameArg notNil ifTrue:[ |
16875 serviceNameArg notNil ifTrue:[ |
16874 serviceName := serviceNameArg printString. "convert integer port numbers" |
16876 serviceName := serviceNameArg printString. "convert integer port numbers" |
16875 serviceNameArg isInteger ifTrue:[ |
16877 serviceNameArg isInteger ifTrue:[ |
16876 port := serviceNameArg. |
16878 port := serviceNameArg. |
16877 ]. |
16879 ]. |
16878 ]. "ifFalse:[serviceName := nil]" |
16880 ]. "ifFalse:[serviceName := nil]" |
|
16881 |
|
16882 |
|
16883 %{ |
|
16884 #if 1 || !defined(AI_NUMERICHOST) |
|
16885 %}. |
|
16886 |
|
16887 "have to convert serviceName and hostName to single byte strings |
|
16888 until we implement getAddrInfoW() for Borland C. |
|
16889 If we really have 16-bit hostnames, this fails with #primitiveFailed" |
|
16890 hostName := hostNameArg asSingleByteStringIfPossible. |
|
16891 serviceName notNil ifTrue:[ |
|
16892 serviceName := serviceName asSingleByteStringIfPossible. |
|
16893 ]. |
|
16894 %{ |
|
16895 #endif // !AI_NUMERICHOST |
|
16896 %}. |
|
16897 |
16879 |
16898 |
16880 %{ /* STACK:32000 */ |
16899 %{ /* STACK:32000 */ |
16881 #if !defined(NO_SOCKET) |
16900 #if !defined(NO_SOCKET) |
16882 char *__hostName, *__serviceName; |
16901 char *__hostName, *__serviceName; |
16883 char __hostNameCopy[1024], __serviceNameCopy[256]; |
16902 char __hostNameCopy[1024], __serviceNameCopy[256]; |
16884 int ret; |
16903 int ret; |
16885 int cnt = 0; |
16904 int cnt = 0; |
16886 |
16905 |
16887 if (hostName == nil) { |
16906 if (hostName == nil) { |
16888 __hostName = 0; |
16907 __hostName = 0; |
16889 } else if (__isStringLike(hostName)) { |
16908 } else if (__isStringLike(hostName)) { |
16890 strncpy(__hostNameCopy, __stringVal(hostName), sizeof(__hostNameCopy)-1); |
16909 strncpy(__hostNameCopy, __stringVal(hostName), sizeof(__hostNameCopy)-1); |
16891 __hostName = __hostNameCopy; |
16910 __hostName = __hostNameCopy; |
|
16911 } else if (__isUnicode16String(hostName)) { |
|
16912 error = @symbol(unsupportedUnicodeName); |
|
16913 errorString = __MKSTRING("Unicode hostnames are not yet supported"); |
|
16914 goto exitPrim; |
16892 } else { |
16915 } else { |
16893 error = @symbol(badArgument1); |
16916 error = @symbol(badArgument1); |
16894 goto exitPrim; |
16917 goto exitPrim; |
16895 } |
16918 } |
16896 if (serviceName == nil) { |
16919 if (serviceName == nil) { |
16897 __serviceName = 0; |
16920 __serviceName = 0; |
16898 } else if (__isStringLike(serviceName)) { |
16921 } else if (__isStringLike(serviceName)) { |
16899 strncpy(__serviceNameCopy, __stringVal(serviceName), sizeof(__serviceNameCopy)-1); |
16922 strncpy(__serviceNameCopy, __stringVal(serviceName), sizeof(__serviceNameCopy)-1); |
16900 __serviceName = __serviceNameCopy; |
16923 __serviceName = __serviceNameCopy; |
16901 } else { |
16924 } else { |
16902 error = @symbol(badArgument2); |
16925 error = @symbol(badArgument2); |
16903 goto exitPrim; |
16926 goto exitPrim; |
16904 } |
16927 } |
16905 if (__hostName == 0 && __serviceName == 0) { |
16928 if (__hostName == 0 && __serviceName == 0) { |
16906 error = @symbol(badArgument); |
16929 error = @symbol(badArgument); |
16907 goto exitPrim; |
16930 goto exitPrim; |
16908 } |
16931 } |
16909 |
16932 |
16910 { |
16933 { |
16911 # if defined(AI_NUMERICHOST) |
16934 # if defined(AI_NUMERICHOST) |
16912 /* |
16935 /* |
16918 struct addrinfo hints; |
16941 struct addrinfo hints; |
16919 struct addrinfo *info = NULL, *infop; |
16942 struct addrinfo *info = NULL, *infop; |
16920 |
16943 |
16921 memset(&hints, 0, sizeof(hints)); |
16944 memset(&hints, 0, sizeof(hints)); |
16922 if (__isSmallInteger(domain)) |
16945 if (__isSmallInteger(domain)) |
16923 hints.ai_family = __intVal(domain); |
16946 hints.ai_family = __intVal(domain); |
16924 if (__isSmallInteger(type)) |
16947 if (__isSmallInteger(type)) |
16925 hints.ai_socktype = __intVal(type); |
16948 hints.ai_socktype = __intVal(type); |
16926 if (__isSmallInteger(proto)) |
16949 if (__isSmallInteger(proto)) |
16927 hints.ai_protocol = __intVal(proto); |
16950 hints.ai_protocol = __intVal(proto); |
16928 |
16951 |
16929 do { |
16952 do { |
16930 # ifdef DO_WRAP_CALLS |
16953 # ifdef DO_WRAP_CALLS |
16931 do { |
16954 do { |
16932 __threadErrno = 0; |
16955 __threadErrno = 0; |
16933 // do not cast to INT - will loose sign bit then! |
16956 // do not cast to INT - will loose sign bit then! |
16934 ret = STX_WSA_NOINT_CALL4( "getaddrinfo", getaddrinfo, __hostName, __serviceName, &hints, &info); |
16957 ret = STX_WSA_NOINT_CALL4( "getaddrinfo", getaddrinfo, __hostName, __serviceName, &hints, &info); |
16935 } while ((ret < 0) && (__threadErrno == EINTR)); |
16958 } while ((ret < 0) && (__threadErrno == EINTR)); |
16936 # else |
16959 # else |
16937 __BEGIN_INTERRUPTABLE__ |
16960 __BEGIN_INTERRUPTABLE__ |
16938 ret = getaddrinfo(__hostName, __serviceName, &hints, &info); |
16961 ret = getaddrinfo(__hostName, __serviceName, &hints, &info); |
16939 __END_INTERRUPTABLE__ |
16962 __END_INTERRUPTABLE__ |
16940 # endif |
16963 # endif |
16941 } while (ret != 0 && __threadErrno == EINTR); |
16964 } while (ret != 0 && __threadErrno == EINTR); |
16942 if (ret != 0) { |
16965 if (ret != 0) { |
16943 switch (ret) { |
16966 switch (ret) { |
16944 case EAI_FAMILY: |
16967 case EAI_FAMILY: |
16945 error = @symbol(badProtocol); |
16968 error = @symbol(badProtocol); |
16946 break; |
16969 break; |
16947 case EAI_SOCKTYPE: |
16970 case EAI_SOCKTYPE: |
16948 error = @symbol(badSocketType); |
16971 error = @symbol(badSocketType); |
16949 break; |
16972 break; |
16950 case EAI_BADFLAGS: |
16973 case EAI_BADFLAGS: |
16951 error = @symbol(badFlags); |
16974 error = @symbol(badFlags); |
16952 break; |
16975 break; |
16953 case EAI_NONAME: |
16976 case EAI_NONAME: |
16954 error = @symbol(unknownHost); |
16977 error = @symbol(unknownHost); |
16955 break; |
16978 break; |
16956 case EAI_SERVICE: |
16979 case EAI_SERVICE: |
16957 error = @symbol(unknownService); |
16980 error = @symbol(unknownService); |
16958 break; |
16981 break; |
16959 case EAI_MEMORY: |
16982 case EAI_MEMORY: |
16960 error = @symbol(allocationFailure); |
16983 error = @symbol(allocationFailure); |
16961 break; |
16984 break; |
16962 case EAI_FAIL: |
16985 case EAI_FAIL: |
16963 error = @symbol(permanentFailure); |
16986 error = @symbol(permanentFailure); |
16964 break; |
16987 break; |
16965 case EAI_AGAIN: |
16988 case EAI_AGAIN: |
16966 error = @symbol(tryAgain); |
16989 error = @symbol(tryAgain); |
16967 break; |
16990 break; |
16968 default: |
16991 default: |
16969 error = @symbol(unknownError); |
16992 error = @symbol(unknownError); |
16970 } |
16993 } |
16971 errorString = __MKSTRING(gai_strerror(ret)); |
16994 errorString = __MKSTRING(gai_strerror(ret)); |
16972 goto err; |
16995 goto err; |
16973 } |
16996 } |
16974 for (cnt=0, infop=info; infop; infop=infop->ai_next) |
16997 for (cnt=0, infop=info; infop; infop=infop->ai_next) |
16975 cnt++; |
16998 cnt++; |
16976 |
16999 |
16977 result = __ARRAY_NEW_INT(cnt); |
17000 result = __ARRAY_NEW_INT(cnt); |
16978 if (result == nil) { |
17001 if (result == nil) { |
16979 error = @symbol(allocationFailure); |
17002 error = @symbol(allocationFailure); |
16980 goto err; |
17003 goto err; |
16981 } |
17004 } |
16982 for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) { |
17005 for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) { |
16983 OBJ o, resp; |
17006 OBJ o, resp; |
16984 |
17007 |
16985 resp = __ARRAY_NEW_INT(6); |
17008 resp = __ARRAY_NEW_INT(6); |
16986 if (resp == nil) { |
17009 if (resp == nil) { |
16987 error = @symbol(allocationFailure); |
17010 error = @symbol(allocationFailure); |
16988 goto err; |
17011 goto err; |
16989 } |
17012 } |
16990 |
17013 |
16991 __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp); |
17014 __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp); |
16992 |
17015 |
16993 __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags); |
17016 __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags); |
16994 __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family); |
17017 __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family); |
16995 __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype); |
17018 __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype); |
16996 __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol); |
17019 __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol); |
16997 |
17020 |
16998 __PROTECT__(resp); |
17021 __PROTECT__(resp); |
16999 o = __BYTEARRAY_NEW_INT(infop->ai_addrlen); |
17022 o = __BYTEARRAY_NEW_INT(infop->ai_addrlen); |
17000 __UNPROTECT__(resp); |
17023 __UNPROTECT__(resp); |
17001 if (o == nil) { |
17024 if (o == nil) { |
17002 error = @symbol(allocationFailure); |
17025 error = @symbol(allocationFailure); |
17003 goto err; |
17026 goto err; |
17004 } |
17027 } |
17005 memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen); |
17028 memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen); |
17006 __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o); |
17029 __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o); |
17007 |
17030 |
17008 if (infop->ai_canonname) { |
17031 if (infop->ai_canonname) { |
17009 __PROTECT__(resp); |
17032 __PROTECT__(resp); |
17010 o = __MKSTRING(infop->ai_canonname); |
17033 o = __MKSTRING(infop->ai_canonname); |
17011 __UNPROTECT__(resp); |
17034 __UNPROTECT__(resp); |
17012 if (o == nil) { |
17035 if (o == nil) { |
17013 error = @symbol(allocationFailure); |
17036 error = @symbol(allocationFailure); |
17014 goto err; |
17037 goto err; |
17015 } |
17038 } |
17016 __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o); |
17039 __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o); |
17017 } |
17040 } |
17018 } |
17041 } |
17019 |
17042 |
17020 err: |
17043 err: |
17021 if (info) freeaddrinfo(info); |
17044 if (info) freeaddrinfo(info); |
17022 |
17045 |
17029 char **addrpp; |
17052 char **addrpp; |
17030 int __port = 0; |
17053 int __port = 0; |
17031 int i; |
17054 int i; |
17032 |
17055 |
17033 if (__isSmallInteger(port)) { |
17056 if (__isSmallInteger(port)) { |
17034 __port = htons(__smallIntegerVal(port)); |
17057 __port = htons(__smallIntegerVal(port)); |
17035 } else if (__serviceName) { |
17058 } else if (__serviceName) { |
17036 struct servent *sp; |
17059 struct servent *sp; |
17037 char *__proto = 0; |
17060 char *__proto = 0; |
17038 |
17061 |
17039 if (__isStringLike(protoArg)) |
17062 if (__isStringLike(protoArg)) |
17040 __proto = __stringVal(protoArg); |
17063 __proto = __stringVal(protoArg); |
17041 |
17064 |
17042 sp = getservbyname(__serviceName, __proto); |
17065 sp = getservbyname(__serviceName, __proto); |
17043 if (sp == NULL) { |
17066 if (sp == NULL) { |
17044 __port = atoi(__serviceName); |
17067 __port = atoi(__serviceName); |
17045 if (__port <= 0) { |
17068 if (__port <= 0) { |
17046 errorString = @symbol(unknownService); |
17069 errorString = @symbol(unknownService); |
17047 error = __mkSmallInteger(-3); |
17070 error = __mkSmallInteger(-3); |
17048 goto err; |
17071 goto err; |
17049 } |
17072 } |
17050 __port = htons(__port); |
17073 __port = htons(__port); |
17051 } else |
17074 } else |
17052 __port = sp->s_port; |
17075 __port = sp->s_port; |
17053 } |
17076 } |
17054 |
17077 |
17055 if (__hostName) { |
17078 if (__hostName) { |
17056 int err; |
17079 int err; |
17057 |
17080 |
17058 do { |
17081 do { |
17059 # if 0 && defined(DO_WRAP_CALLS) |
17082 # if 0 && defined(DO_WRAP_CALLS) |
17060 /* This does not work - the structure is allocated in thread local storage */ |
17083 /* This does not work - the structure is allocated in thread local storage */ |
17061 hp = STX_WSA_NOINT_CALL1("gethostbyname", gethostbyname, __hostName); |
17084 hp = STX_WSA_NOINT_CALL1("gethostbyname", gethostbyname, __hostName); |
17062 if ((INT)hp < 0) hp = NULL; |
17085 if ((INT)hp < 0) hp = NULL; |
17063 # else |
17086 # else |
17064 /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname |
17087 /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname |
17065 * uses a static data area, but allocates it in thread local storage |
17088 * uses a static data area, but allocates it in thread local storage |
17066 */ |
17089 */ |
17067 // __BEGIN_INTERRUPTABLE__ |
17090 // __BEGIN_INTERRUPTABLE__ |
17068 hp = gethostbyname(__hostName); |
17091 hp = gethostbyname(__hostName); |
17069 // __END_INTERRUPTABLE__ |
17092 // __END_INTERRUPTABLE__ |
17070 #endif |
17093 #endif |
17071 } while ((hp == NULL |
17094 } while ((hp == NULL |
17072 && (err = WSAGetLastError()) == EINTR |
17095 && (err = WSAGetLastError()) == EINTR |
17073 || err == TRY_AGAIN)); |
17096 || err == TRY_AGAIN)); |
17074 if (hp == 0) { |
17097 if (hp == 0) { |
17075 switch (err) { |
17098 switch (err) { |
17076 case HOST_NOT_FOUND: |
17099 case HOST_NOT_FOUND: |
17077 errorString = @symbol(unknownHost); |
17100 errorString = @symbol(unknownHost); |
17078 break; |
17101 break; |
17079 case NO_ADDRESS: |
17102 case NO_ADDRESS: |
17080 errorString = @symbol(noAddress); |
17103 errorString = @symbol(noAddress); |
17081 break; |
17104 break; |
17082 case NO_RECOVERY: |
17105 case NO_RECOVERY: |
17083 errorString = @symbol(permanentFailure); |
17106 errorString = @symbol(permanentFailure); |
17084 break; |
17107 break; |
17085 case TRY_AGAIN: |
17108 case TRY_AGAIN: |
17086 errorString = @symbol(tryAgain); |
17109 errorString = @symbol(tryAgain); |
17087 break; |
17110 break; |
17088 default: |
17111 default: |
17089 errorString = @symbol(unknownError); |
17112 errorString = @symbol(unknownError); |
17090 break; |
17113 break; |
17091 } |
17114 } |
17092 error = __mkSmallInteger(err); |
17115 error = __mkSmallInteger(err); |
17093 goto err; |
17116 goto err; |
17094 } |
17117 } |
17095 |
17118 |
17096 if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) { |
17119 if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) { |
17097 errorString = @symbol(unknownHost); |
17120 errorString = @symbol(unknownHost); |
17098 error = __mkSmallInteger(-2); |
17121 error = __mkSmallInteger(-2); |
17099 goto err; |
17122 goto err; |
17100 } |
17123 } |
17101 |
17124 |
17102 for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++) |
17125 for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++) |
17103 cnt++; |
17126 cnt++; |
17104 addrpp = hp->h_addr_list; |
17127 addrpp = hp->h_addr_list; |
17105 } else { |
17128 } else { |
17106 cnt = 1; |
17129 cnt = 1; |
17107 } |
17130 } |
17108 |
17131 |
17109 result = __ARRAY_NEW_INT(cnt); |
17132 result = __ARRAY_NEW_INT(cnt); |
17110 if (result == nil) { |
17133 if (result == nil) { |
17111 error = @symbol(allocationFailure); |
17134 error = @symbol(allocationFailure); |
17112 goto err; |
17135 goto err; |
17113 } |
17136 } |
17114 |
17137 |
17115 for (i = 0; i < cnt; i++) { |
17138 for (i = 0; i < cnt; i++) { |
17116 OBJ o, resp; |
17139 OBJ o, resp; |
17117 struct sockaddr_in *sa; |
17140 struct sockaddr_in *sa; |
17118 |
17141 |
17119 resp = __ARRAY_NEW_INT(6); |
17142 resp = __ARRAY_NEW_INT(6); |
17120 if (resp == nil) { |
17143 if (resp == nil) { |
17121 error = @symbol(allocationFailure); |
17144 error = @symbol(allocationFailure); |
17122 goto err; |
17145 goto err; |
17123 } |
17146 } |
17124 |
17147 |
17125 __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp); |
17148 __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp); |
17126 __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0); |
17149 __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0); |
17127 __ArrayInstPtr(resp)->a_element[2] = type; __STORE(resp, type); |
17150 __ArrayInstPtr(resp)->a_element[2] = type; __STORE(resp, type); |
17128 __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(resp, proto); |
17151 __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(resp, proto); |
17129 __PROTECT__(resp); |
17152 __PROTECT__(resp); |
17130 o = __BYTEARRAY_NEW_INT(sizeof(*sa)); |
17153 o = __BYTEARRAY_NEW_INT(sizeof(*sa)); |
17131 __UNPROTECT__(resp); |
17154 __UNPROTECT__(resp); |
17132 if (o == nil) { |
17155 if (o == nil) { |
17133 error = @symbol(allocationFailure); |
17156 error = @symbol(allocationFailure); |
17134 goto err; |
17157 goto err; |
17135 } |
17158 } |
17136 __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o); |
17159 __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o); |
17137 sa = (struct sockaddr_in *)__byteArrayVal(o); |
17160 sa = (struct sockaddr_in *)__byteArrayVal(o); |
17138 sa->sin_port = __port; |
17161 sa->sin_port = __port; |
17139 |
17162 |
17140 if (__hostName) { |
17163 if (__hostName) { |
17141 sa->sin_family = hp->h_addrtype; |
17164 sa->sin_family = hp->h_addrtype; |
17142 memcpy(&sa->sin_addr, *addrpp, hp->h_length); |
17165 memcpy(&sa->sin_addr, *addrpp, hp->h_length); |
17143 __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype); |
17166 __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype); |
17144 if (hp->h_name) { |
17167 if (hp->h_name) { |
17145 __PROTECT__(resp); |
17168 __PROTECT__(resp); |
17146 o = __MKSTRING(hp->h_name); |
17169 o = __MKSTRING(hp->h_name); |
17147 __UNPROTECT__(resp); |
17170 __UNPROTECT__(resp); |
17148 if (o == nil) { |
17171 if (o == nil) { |
17149 error = @symbol(allocationFailure); |
17172 error = @symbol(allocationFailure); |
17150 goto err; |
17173 goto err; |
17151 } |
17174 } |
17152 __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o); |
17175 __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o); |
17153 } |
17176 } |
17154 addrpp++; |
17177 addrpp++; |
17155 } else{ |
17178 } else{ |
17156 if (__isSmallInteger(domain)) |
17179 if (__isSmallInteger(domain)) |
17157 sa->sin_family = __intVal(domain); |
17180 sa->sin_family = __intVal(domain); |
17158 else |
17181 else |
17159 sa->sin_family = AF_INET; |
17182 sa->sin_family = AF_INET; |
17160 __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain); |
17183 __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain); |
17161 } |
17184 } |
17162 } |
17185 } |
17163 |
17186 |
17164 err:; |
17187 err:; |
17165 # endif /* ! AI_NUMERICHOST */ |
17188 # endif /* ! AI_NUMERICHOST */ |
17166 } |
17189 } |
17168 error = @symbol(notImplemented); |
17191 error = @symbol(notImplemented); |
17169 #endif |
17192 #endif |
17170 exitPrim:; |
17193 exitPrim:; |
17171 %}. |
17194 %}. |
17172 error notNil ifTrue:[ |
17195 error notNil ifTrue:[ |
17173 |request| |
17196 |request| |
17174 error isSymbol ifTrue:[ |
17197 request := SocketAddressInfo new |
17175 self primitiveFailed:error. |
17198 domain:domainArg; |
17176 ]. |
17199 type:typeArg; |
17177 request := SocketAddressInfo new |
17200 protocol:protoArg; |
17178 domain:domainArg; |
17201 canonicalName:hostName; |
17179 type:typeArg; |
17202 serviceName:serviceName. |
17180 protocol:protoArg; |
17203 ^ (HostNameLookupError new |
17181 canonicalName:hostName; |
17204 parameter:error; |
17182 serviceName:serviceName. |
17205 messageText:' - ', (errorString ? error printString); |
17183 ^ (HostNameLookupError new |
17206 request:request) raiseRequest. |
17184 parameter:error; |
|
17185 messageText:' - ', (errorString ? error printString); |
|
17186 request:request) raiseRequest. |
|
17187 ]. |
17207 ]. |
17188 1 to:result size do:[:i | |
17208 1 to:result size do:[:i | |
17189 |entry dom info| |
17209 |entry dom info| |
17190 |
17210 |
17191 info := SocketAddressInfo new. |
17211 info := SocketAddressInfo new. |
17192 entry := result at:i. |
17212 entry := result at:i. |
17193 info flags:(entry at:1). |
17213 info flags:(entry at:1). |
17194 info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)). |
17214 info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)). |
17195 info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)). |
17215 info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)). |
17196 info protocol:(self protocolSymbolOf:(entry at:4)). |
17216 info protocol:(self protocolSymbolOf:(entry at:4)). |
17197 info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)). |
17217 info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)). |
17198 info canonicalName:(entry at:6). |
17218 info canonicalName:(entry at:6). |
17199 result at:i put:info |
17219 result at:i put:info |
17200 ]. |
17220 ]. |
17201 ^ result |
17221 ^ result |
17202 |
17222 |
17203 " |
17223 " |
17204 self getAddressInfo:'localhost' serviceName:nil |
17224 self getAddressInfo:'localhost' serviceName:nil |
17205 domain:nil type:nil protocol:nil flags:nil |
17225 domain:nil type:nil protocol:nil flags:nil |
17206 self getAddressInfo:'localhost' serviceName:nil |
17226 self getAddressInfo:'localhost' serviceName:nil |
17207 domain:#AF_INET type:#stream protocol:nil flags:nil |
17227 domain:#AF_INET type:#stream protocol:nil flags:nil |
17208 self getAddressInfo:'localhost' serviceName:nil |
17228 self getAddressInfo:'localhost' serviceName:nil |
17209 domain:#AF_INET type:#stream protocol:#tcp flags:nil |
17229 domain:#AF_INET type:#stream protocol:#tcp flags:nil |
17210 self getAddressInfo:'localhost' serviceName:10 |
17230 self getAddressInfo:'localhost' serviceName:10 |
17211 domain:#AF_INET type:#stream protocol:#tcp flags:nil |
17231 domain:#AF_INET type:#stream protocol:#tcp flags:nil |
17212 self getAddressInfo:'localhost' serviceName:'10' |
17232 self getAddressInfo:'localhost' serviceName:'10' |
17213 domain:#AF_INET type:#stream protocol:#tcp flags:nil |
17233 domain:#AF_INET type:#stream protocol:#tcp flags:nil |
17214 self getAddressInfo:'blurb.exept.de' serviceName:nil |
17234 self getAddressInfo:'blurb.exept.de' serviceName:nil |
17215 domain:#AF_INET type:nil protocol:nil flags:nil |
17235 domain:#AF_INET type:nil protocol:nil flags:nil |
17216 self getAddressInfo:'1.2.3.4' serviceName:'bla' |
17236 self getAddressInfo:'1.2.3.4' serviceName:'bla' |
17217 domain:#AF_INET type:nil protocol:nil flags:nil |
17237 domain:#AF_INET type:nil protocol:nil flags:nil |
17218 self getAddressInfo:'localhost' serviceName:'echo' |
17238 self getAddressInfo:'localhost' serviceName:'echo' |
17219 domain:#AF_INET type:nil protocol:nil flags:nil |
17239 domain:#AF_INET type:nil protocol:nil flags:nil |
17220 self getAddressInfo:nil serviceName:'echo' |
17240 self getAddressInfo:nil serviceName:'echo' |
17221 domain:#AF_INET type:nil protocol:nil flags:nil |
17241 domain:#AF_INET type:nil protocol:nil flags:nil |
17222 self getAddressInfo:nil serviceName:nil |
17242 self getAddressInfo:nil serviceName:nil |
17223 domain:#AF_INET type:nil protocol:nil flags:nil |
17243 domain:#AF_INET type:nil protocol:nil flags:nil |
17224 self getAddressInfo:'www.google.de' serviceName:nil |
17244 self getAddressInfo:'www.google.de' serviceName:nil |
17225 domain:nil type:nil protocol:nil flags:nil |
17245 domain:nil type:nil protocol:nil flags:nil |
17226 self getAddressInfo:'smc1' serviceName:nil |
17246 self getAddressInfo:'exeptn' serviceName:nil |
17227 domain:nil type:nil protocol:nil flags:nil |
17247 domain:nil type:nil protocol:nil flags:nil |
|
17248 |
|
17249 self getAddressInfo:'localhost' asUnicode16String serviceName:nil |
|
17250 domain:nil type:nil protocol:nil flags:nil |
|
17251 self getAddressInfo:'ützlbrützl' serviceName:nil |
|
17252 domain:nil type:nil protocol:nil flags:nil |
|
17253 self getAddressInfo:'ützlbrützl' serviceName:nil |
|
17254 domain:nil type:nil protocol:nil flags:nil |
|
17255 self getAddressInfo:'путин.ру' asUnicode16String serviceName:nil |
|
17256 domain:nil type:nil protocol:nil flags:nil |
17228 " |
17257 " |
17229 ! |
17258 ! |
17230 |
17259 |
17231 getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags |
17260 getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags |
17232 "answer an Array containing the hostName and serviceName |
17261 "answer an Array containing the hostName and serviceName |