public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Maybe a bug with sockets
@ 2002-01-09  9:31 Stefan Frings
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Frings @ 2002-01-09  9:31 UTC (permalink / raw)
  To: cygwin

Hello,

Please send your answer to ms.frings@mail.isis.de because I do not read the 
mailing list very often. Thanks.

I think I found a bug in cygwin. I open a socket connection and start a 
child process after that. Then I cannot close the socket. The following is 
a reduced source code with that problem. It works fine on Linux but not on 
CygWin.

Compile and run it. The use "telnet localhost 80" to test it. You should 
see the message "Hello" and then a disconnect message. But the disconnect 
message is missed until you kill the child process.



#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <errno.h>

#define PORT 80                         // Port for TCP/IP Sockets


int main(int argc,char** argv)
{
  struct sockaddr_in address;
  int sock;
  sock=socket(PF_INET,SOCK_STREAM,0);
  setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,0,0);
  address.sin_family=AF_INET;
  address.sin_port=htons(PORT);
  memset(&address.sin_addr,0,sizeof(address.sin_addr));
  bind(sock,(struct sockaddr *) &address,sizeof(address));
  listen(sock,5);
  {
    size_t addrlength;
    int verbindung;
    addrlength=sizeof(address);
    verbindung=accept(sock,(struct sockaddr *) &address,&addrlength);
    if (verbindung>=0)
    {
      printf("Verbindung aufgebaut\n");
      write(verbindung,"Hello\n",6);


      if (fork()==0)
              {
                // Child
                close(verbindung);
                while (1)
                {
                  printf("Child is running\n");
                  sleep(3);
                }
                exit(0);
              }
      else
      {
        // Mother
        close(verbindung);
      }


    }
  }
  return 0;
}

--
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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Maybe a bug with sockets
       [not found] <200201091728.g09HSq009591@spf7.us4.outblaze.com>
@ 2002-01-09 12:02 ` ricardo niederberger cabral
  0 siblings, 0 replies; 2+ messages in thread
From: ricardo niederberger cabral @ 2002-01-09 12:02 UTC (permalink / raw)
  To: cygwinmlist; +Cc: ms.frings

This is a known bug in cygwin1.dll. It has been corrected on the CVS
version. Try a CVS snapshot release of cygwin1.dll.
---
Ricardo Niederberger Cabral
<rnc@brturbo.com>
----- Original Message -----
From: "Stefan Frings" <s.frings@mail.isis.de>
To: <cygwin@cygwin.com>
Sent: Wednesday, January 09, 2002 3:32 PM
Subject: Maybe a bug with sockets


> I think I found a bug in cygwin. I open a socket connection and start a
> child process after that. Then I cannot close the socket. The following is
> a reduced source code with that problem. It works fine on Linux but not on
> CygWin.



--
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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-09 20:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-09  9:31 Maybe a bug with sockets Stefan Frings
     [not found] <200201091728.g09HSq009591@spf7.us4.outblaze.com>
2002-01-09 12:02 ` ricardo niederberger cabral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).