Solved

Client recv on TCP/IP

Posted on 2012-04-03
2
458 Views
Last Modified: 2012-04-04
Currently I have a blocking read on a client socket on an AIX 5.3 system on a thread.
Problem is that I have received a message to shutdown, where I need to close the client socket and perform other cleanup.  I have read that the default is blocking read. I have read the man pages and cannot see how one makes it a non-blocking read.  What is the "common" way to manage this kind of problem?  Does one make the read blocking with a wait timeout? Cannot see in IBM manuals how one does this.  Thanks in advance.
0
Comment
Question by:bachan312
2 Comments
 
LVL 40

Accepted Solution

by:
noci earned 500 total points
ID: 37806928
non-blocking io is done by using a setsockopt call O_NONBLK, then waiting in a select() for one of several filedescriptors and/or a timer
and when select indicates one of your descriptors is ready [ this is communicated using bitmaps ]  you can read/write that descriptor.

This mostly used when non-threaded code is used to implement f.e. a server handling several connections.  [ it predates threading / coroutines  as a way to have some parallelism.

You are using threading, why not just close the socket  and/or kill the thread?
Another thread can handle the shutdown...
0
 

Author Closing Comment

by:bachan312
ID: 37807735
A simple solution.
Thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now