- if (!silc_idcache_list_first(list, &id_cache)) {
- silc_idcache_list_free(list);
- return NULL;
- }
-
- while (id_cache) {
- server = (SilcServerEntry)id_cache->context;
- sock = (SilcSocketConnection)server->connection;
-
- if (sock && ((sock->hostname && !strcasecmp(sock->hostname, hostname)) ||
- (sock->ip && !strcasecmp(sock->ip, hostname)))
- && server->id->port == SILC_SWAB_16(port))
- break;
+ silc_list_start(list);
+ while ((id_cache = silc_list_get(list))) {
+ server = id_cache->context;
+ sock = server->connection;
+
+ if (sock && silc_socket_stream_get_info(
+ silc_packet_stream_get_stream(sock),
+ NULL, &host, &ip, NULL)) {
+ if (((host && !strcasecmp(host, hostname)) ||
+ (ip && !strcasecmp(ip, hostname))) &&
+ server->id->port == SILC_SWAB_16(port))
+ break;
+ }