Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <40668DD4ED0FD511B74100E018043B73A51687@brub002a.siemens.be> From: DEVRIENDT ERIK To: "'cygwin AT cygwin DOT com'" Subject: RE: connect() does not work with UNIX domain datagram sockets Date: Tue, 2 Apr 2002 18:32:41 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Some additional information about my problem : cygwin 1.3.10 running on Windows NT 4.0. Here follows a set of programs (client.c, server.c) that exhibit the problem. If you #define USE_SENDTO in client.c, the communication works. I will also send a strace to Egor Duda. Erik Devriendt # ---------- makefile ------------- all: server client client: client.c gcc -o client client.c server: server.c gcc -o server server.c # --------- end of makefile ------ /* ------- begin of server.c ------------ */ #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { struct sockaddr_un name; int socket_id; int s; struct sockaddr saddr; int saddrlen; char buf[1024]; int result; name.sun_family = AF_UNIX; strcpy(name.sun_path, "./testsock"); if ((socket_id=socket(AF_UNIX, SOCK_DGRAM,0)) <0 ) { printf("socket() gave errno = %d : %s\n", errno, strerror(errno)); exit(1); } if ((bind(socket_id,(struct sockaddr *)&name,sizeof(name))) <0) { printf("bind() gave errno = %d : %s\n", errno, strerror(errno)); exit(1); } printf("OK, socket_id = %d\n", socket_id); result = read(socket_id, buf, sizeof(buf)); if(result > 0) printf("read %d bytes : <%s>\n", result, buf); return 0; } /* ------- end of server.c ------------ */ /* ------- begin of client.c ------------ */ #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { struct sockaddr_un name; int socket_id, socket_id2; char buf[100]; int sendresult; name.sun_family = AF_UNIX; strcpy(name.sun_path, "./testsock"); if ((socket_id=socket(AF_UNIX, SOCK_DGRAM,0)) <0 ) { printf("socket() gave errno = %d : %s\n", errno, strerror(errno)); exit(1); } strcpy(buf, "hallo\n"); /* #define USE_SENDTO */ #ifdef USE_SENDTO sendresult = sendto(socket_id, buf, strlen(buf)+1, 0, (struct sockaddr *)&name, sizeof(name) ); #else if ( connect(socket_id, (struct sockaddr *)&name, sizeof(name)) < 0) { printf("connect() gave errno = %d : %s\n", errno, strerror(errno)); exit(1); } sendresult = write(socket_id, buf, strlen(buf)+1); #endif printf("sendresult = %d\n", sendresult); if(sendresult < 0) { printf("sendto() gave errno = %d : %s\n", errno, strerror(errno)); exit(1); } printf("OK, socket_id = %d\n", socket_id); return 0; } /* ------- begin of client.c ------------ */ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/