Solved

Client recv on TCP/IP

Posted on 2012-04-03
2
457 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 39

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

14 Experts available now in Live!

Get 1:1 Help Now