delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/04/07/06:02:10

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 537A29mu1362200
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 537A29mu1362200
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=Ydk9xxLh
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8980384CBAC
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1744020127;
bh=VQ+Q4etkzPBLUgXQbsjo1qWTmS26PZ/tBLOHwYtRX1A=;
h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=Ydk9xxLhNWCwqmzdzojbXYF+QYV7vI4ZqI9BWTAJpny8dEuD3AN9gtqXb/5xEfNH1
/9DOETPVnoCCvabaKgMo/A+bX5Z5+ms+W5IS703dkisvMkBAJUX50F4emtwEd7WI0B
ibW3Cad1MM0d6ykWoFIR7pPrrgy4g4VO99WE5boc=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9E24384D17C
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D9E24384D17C
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744020056; cv=none;
b=s1WaaQB08xdbyhLoIEDEgew0IpuNawTFRUQYzmD/tyG76wdxhQ1wZTAmuXuyJB0n1sMjk2PDSL3pcOjsoqj8SwG/W62CUPmSMYKF+ZOWX/d/7RYi5gj+M+GQPbpU3pnMnT8KiuGdbiRF00VdldnlbQEEUuEYQY20xOukWM+cels=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1744020056; c=relaxed/simple;
bh=CQrRqt+BUZR2kMcbDSafSC9BQzByew9mRZz5x/FpB+k=;
h=Subject:To:From:Message-ID:Date:MIME-Version;
b=qJKuK/Ees1fZeWySyQINjb04+XD2XjFOr9iszsNIhwVIfOHoUUbKlkBG2W+J6f2Q8BB7IsnZ6Ufvu3xiLmmzSo/BJkKVY4KmNvZ2XTDEGA9qRj8cZzd56njtUY6Z0gNpxzlsiWTpRYEUGnI3NPWd9mxrbH7Mg7m5DP60hujPNcw=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9E24384D17C
Subject: Re: unix socket hang when connect
To: cygwin AT cygwin DOT com
References: <TYCPR01MB10926FF8926CA63704867ADC8F8AA2 AT TYCPR01MB10926 DOT jpnprd01 DOT prod DOT outlook DOT com>
Message-ID: <373e15fd-49ec-ca3c-2c9b-1243ae6479a7@t-online.de>
Date: Mon, 7 Apr 2025 12:00:51 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101
SeaMonkey/2.53.20
MIME-Version: 1.0
In-Reply-To: <TYCPR01MB10926FF8926CA63704867ADC8F8AA2@TYCPR01MB10926.jpnprd01.prod.outlook.com>
X-TOI-EXPURGATEID: 150726::1744020050-9F7EF2F9-4C3EDA2D/0/0 CLEAN NORMAL
X-TOI-MSGID: 0f831d57-6ccf-4e49-8a6e-796e1d1db9d7
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Christian Franke via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Christian Franke <Christian DOT Franke AT t-online DOT de>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

Yuyi Wang via Cygwin wrote:
> Below is a simple unix socket testing code. It creates a unix socket server and
> a client to connect to it immediately. It works on Linux and macOS, but hangs on
> cygwin. bind + listen work well, but seems that the connect method never returns.
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> #include <sys/socket.h>
> #include <sys/un.h>
> #include <errno.h>
>
> #define SOCKET_PATH "/tmp/example_socket"
>
> int main() {
>      int server_fd, client_fd;
>      struct sockaddr_un server_addr;
>      socklen_t client_len;
>
>      server_fd = socket(AF_UNIX, SOCK_STREAM, 0);
>      if (server_fd == -1) {
>          perror("server socket");
>          exit(EXIT_FAILURE);
>      }
>
>      memset(&server_addr, 0, sizeof(server_addr));
>      server_addr.sun_family = AF_UNIX;
>      strncpy(server_addr.sun_path, SOCKET_PATH, sizeof(server_addr.sun_path) - 1);
>
>      if (bind(server_fd, (struct sockaddr*)&server_addr, sizeof(server_addr)) == -1) {
>          perror("bind");
>          exit(EXIT_FAILURE);
>      }
>
>      if (listen(server_fd, 1) == -1) {
>          perror("listen");
>          exit(EXIT_FAILURE);
>      }
>
>      printf("Server is listening on %s\n", SOCKET_PATH);
>
>      client_fd = socket(AF_UNIX, SOCK_STREAM, 0);
>      if (client_fd == -1) {
>          perror("client socket");
>          exit(EXIT_FAILURE);
>      }
>
>      if (connect(client_fd, (struct sockaddr*)&server_addr, sizeof(server_addr)) == -1) {
>          perror("connect");
>          exit(EXIT_FAILURE);
>      }
>
>      printf("Client connected to server\n");
>
>      close(client_fd);
>      close(server_fd);
>      unlink(SOCKET_PATH);
>
>      return 0;
> }

May be this issue which also affected postfix:
https://sourceware.org/legacy-ml/cygwin/2014-08/msg00420.html

Try:
setsockopt(sd, SOL_SOCKET, SO_PEERCRED, NULL, 0);

available since:
https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=697b9afe0
and may still work (I don't know).

-- 
Regards,
Christian


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019