home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!gatech!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!not-for-mail
- From: Christophe.Wolfhugel@grasp.insa-lyon.fr (Christophe Wolfhugel)
- Newsgroups: comp.unix.programmer
- Subject: asynchronously connecting a socket
- Date: 5 Jan 1993 16:53:43 +0100
- Organization: INSA Informatique (Grasp), Lyon, France
- Lines: 30
- Message-ID: <1icau7INNg7f@grasp1.univ-lyon1.fr>
- NNTP-Posting-Host: grasp1.univ-lyon1.fr
-
- The connect(3n) system call when used aynchronously will return -1 with
- errno set to EINPROGRESS. A write select(3n) will indicate completion
- of the connect. Is this an option or is it mandatory ?
-
- In order to check return codes, I used a small loop:
-
- while (connect(f->f_file, &ip, sizeof ip) < 0) {
- fprintf(stderr, "errno = %d\n", errno);
- sleep(1);
- continue;
- } /* endif */
-
- This returns:
-
- errno = 150 (EINPROGRESS)
- errno = 11 (EAGAIN)
- [many other errno = 11]
- Broken pipe
-
- and the application dies. Is this behavior illegal (I know it does not
- make much sense to have such a loop). Shouldn't I get a EALREADY
- instead of the EAGAIN ?
-
- Also, in a select loop. Once select indicates a write even for that
- file description. How do I check the connection ? Redo a connect()
- and except errno to be either EISCONN to indicate success, any other
- result to indicate failure ?
-
- --
- Christophe Wolfhugel | Email: Christophe.Wolfhugel@grasp.insa-lyon.fr
-