Quote:
> > Swapnajit,
> > I finally got the book above. Congratulations.
> > The section about inter-process communications was very helpful.
> > Regarding this issue, I need an advice on the following :
> > The 'accept' call of the server is blocking by default. It will not
> > return until a connection is available. I know that it is possible
to
> > define the socket as non-blocking. Can you advise me how? Actually I
> > want to achieve the effect of the server 'visiting' the socket and
if
> > there is no connection of the client to let it continue.
> > Thank you,
> > Andi Carmon
> Andi,
> I am glad that the example in the book
> has encouraged you to do further research
> on the topic; after all, that is one of the
> main objective of the book.
> Regarding your question, you can create a
> non-blocking socket (by default, all sockets
> are blocking) by using fcntl() system call.
> An example of this is :
> fcntl(s, F_SETFL, FNONBLK);
> where s is the socket created by socket().
> The names of the integer constants may be
> slightly different depending on your version of
> UNIX. For example, when FNONBLK is POSIX
> compliant, IRIX uses a native FNONBLOCK.
> Also, there are other ways to do the same. Some
> flavors of UNIX (and BeOS) does this using
> setsockopt(), but it is not implemented
> in all OS'.
> Thanks,
> - Swapnajit Mittra
> --
> =-=-=-=-=-= 100% pure Verilog PLI - go, get it ! =-=-=-=-=-=
> Principles of Verilog PLI -By- Swapnajit Mittra
> Kluwer Academic Publishers. ISBN: 0-7923-8477-6
> http://www.angelfire.com/ca/verilog/
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Swapnajit,
Thank you for the tip. I think I need only one small additional push.
I defined the server socket as non-blocking (but not the client).
The accept() call is now part of the read_server routine and to check
for availability of new data from client I use poll() as Bob Beckwith
also suggested. The problem is that the ping-pong works only once!
It seems that I need some means to "re-arm" the mechanism.
The sequence I get is as follows: (As I mentioned the server is
triggered in verilog and checks for availability of new data from
client).
client_write; client_read (now waits for server_write).
Later, the server check and successfully detects the pending data.
server_write; client successfully detects server_write and performs
again
client_write; client_read (now waits for server_write).
Now, here is hangs up.
The server, triggered later again, checks but does not detect any more
pending data.
Can you see what the problem is ?
Thank you again, and if you attend DAC I would like to thank you
personally.
Andi Carmon
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.