Solved

Client recv on TCP/IP

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
for ssh without password, are both ways correct 16 72
Error when calling SSH command 20 110
OpenWrt 1 42
Linux on a Dell PowerEdge 720 3 129
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 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