Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!sol.ctr.columbia.edu!news.cs.columbia.edu!news.cs.columbia.edu!news-not-for-mail
From: goel@news.cs.columbia.edu (Shantanu Goel)
Newsgroups: comp.unix.bsd
Subject: Re: Berkley Sockets, Accept System Call.
Date: 21 May 1994 18:45:44 -0400
Organization: Columbia University Department of Computer Science
Lines: 31
Message-ID: <2rm2uo$n7h@tune.cs.columbia.edu>
References: <Cq4A8G.LzC@mail.auburn.edu>
NNTP-Posting-Host: tune.cs.columbia.edu
Keywords: BSD Sockets?
In article <Cq4A8G.LzC@mail.auburn.edu>,
Satish G. Ambati <sgambati@eng.auburn.edu> wrote:
>I am working with Berkley Sockets and I need some Information about the accept
>system call. I am trying to get some information on making my accept system call non-blocking. I am clear with the concept and how it works, however I am having
>some problems in Implementation and getting it to work. If anybody out there is
>a socket Guru and have some kind of code to demonstrate this, I really appreciate
>any responses. Thanx,
>
>Satish.
>
>
>
To make accept() non-blocking, you can select() on the descriptor as
if you were selecting for read(). Here's some pseudo-code.
s = socket(...);
bind(...);
listen(s, ...);
FD_ZERO(readfds)
FD_SET(readfds, s);
select(readfds, ...);
if (FD_ISSET(readfds, s)) {
accept(s, ...);
...
}
Hope this helps.
Shantanu