Sponsored Content
Top Forums Programming Which are blocking and non-blocking api's in sockets in C ? Post 302911449 by DGPickett on Thursday 31st of July 2014 04:33:22 PM
Old 07-31-2014
Somewhere in fctl() is O_NONBLOCK, which changes your sockets or whatever fd so it does not block. https://www.unix.com/man-page/opensolaris/0/fcntl/ Blocking is the default. You can avoid blocking issues by using thread per fd/direction, poll()/select() to detect what is ready, aio (async IO) or nonblocking fd's.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

blocking domains

Dear All , Kindly note I have sun solaries 7 . I want to block a domain who keep sending emails to my domain and users . thanks (1 Reply)
Discussion started by: tamemi
1 Replies

2. IP Networking

School Blocking

I'm in highschool. They blocked my favorite site. How do I disable websense without getting caught on that particular webpage? Is it even possible? *twitch* I would also like to get as much UNIX for beginners information, so if someone might point me in the right direction so I don't have to read... (1 Reply)
Discussion started by: Satine
1 Replies

3. IP Networking

blocking DHCP

I've got a legit DHCP server on my network. I've got a 3550 as my VTP server providing 4 vlans to 4 2950 switches. If somebody were to plug into one of those vlans with a DHCP server configured then it would throw off my whole network. How could i block the DHCP server that could plug into the... (2 Replies)
Discussion started by: byblyk
2 Replies

4. Programming

Linux BSD sockets blocking issue

I am using BSD TCP sockets under Debian Linux 2.6 and no matter what I do, the socket blocks on recv. I have set O_NONBLOCK and O_NDELAY using fcntl to no effect. Any ideas ? (3 Replies)
Discussion started by: johnmb
3 Replies

5. Shell Programming and Scripting

Non-blocking pipe

Hello, Would this be an acceptable way of creating a non-blocking pipe. Basically I want to create kind of a server client arch. This code would be in the server, and I don't want to have to wait for clients to read before moving on to the next client. One problem I can see is if... (4 Replies)
Discussion started by: cdlaforc
4 Replies

6. Shell Programming and Scripting

blocking script help

sed -n '/robots.txt/!{s/\(\{1,\}\.*\.*\.*\).*\/\(.*\.txt\).*/\1 \2/p;}' myaapache.log Above command will search all txt except robots.txt from apache logs and show like 94.136.63.119 idsuper.txt 174.121.67.233 fx29id1.txt I want to block that ip address automatically, i need script... (1 Reply)
Discussion started by: learnbash
1 Replies

7. UNIX for Advanced & Expert Users

ps blocking

Hi Folks I have been debugging a script that is called every thirty seconds. Basically it is doing a ps, well two actually, one to file (read by the getline below) and the other into a pipe. The one into the pipe is: - V_SYSVPS=/usr/sysv/bin/ps $V_SYSVPS -p$PIDLIST -o$PSARGS... (0 Replies)
Discussion started by: steadyonabix
0 Replies

8. UNIX for Dummies Questions & Answers

Blocking signals

I know how to add signal to a set. But what if I want to add 2 or 3 signals to the set. I know I can use sigaddset (&set,SIGBUS)....but what if I want to add SIGBUS and SIGALRM at once. Do i have to do it like this.. sigaddset (&set,SIGBUS); sigaddset (&set,SIGALRM); Is there another way to... (0 Replies)
Discussion started by: joker40
0 Replies

9. Red Hat

Blocking an IP address

Dear all, I am new to this forum.I need some assistant from you people. I have a server in which Linux 5 is installed and it is in the network. How i block any user to access my server.. Upto how many users i can block.. send me the procedure.... Thank you in advance...... (10 Replies)
Discussion started by: sudhansu
10 Replies

10. IP Networking

ping blocking

Hi I am starting to practice nmap for my own education. Now I created two host in virtual box. Bot are scientific linux, one in installed as web server and the other as developing station. I tried to run nmap on so I did nmap on their IP address, I got an answer that ip is down or that... (8 Replies)
Discussion started by: programAngel
8 Replies
IBV_GET_ASYNC_EVENT(3)					  Libibverbs Programmer's Manual				    IBV_GET_ASYNC_EVENT(3)

NAME
ibv_get_async_event, ibv_ack_async_event - get or acknowledge asynchronous events SYNOPSIS
#include <infiniband/verbs.h> int ibv_get_async_event(struct ibv_context *context, struct ibv_async_event *event); void ibv_ack_async_event(struct ibv_async_event *event); DESCRIPTION
ibv_get_async_event() waits for the next async event of the RDMA device context context and returns it through the pointer event, which is an ibv_async_event struct, as defined in <infiniband/verbs.h>. struct ibv_async_event { union { struct ibv_cq *cq; /* CQ that got the event */ struct ibv_qp *qp; /* QP that got the event */ struct ibv_srq *srq; /* SRQ that got the event */ int port_num; /* port number that got the event */ } element; enum ibv_event_type event_type; /* type of the event */ }; One member of the element union will be valid, depending on the event_type member of the structure. event_type will be one of the follow- ing events: QP events: IBV_EVENT_QP_FATAL Error occurred on a QP and it transitioned to error state IBV_EVENT_QP_REQ_ERR Invalid Request Local Work Queue Error IBV_EVENT_QP_ACCESS_ERR Local access violation error IBV_EVENT_COMM_EST Communication was established on a QP IBV_EVENT_SQ_DRAINED Send Queue was drained of outstanding messages in progress IBV_EVENT_PATH_MIG A connection has migrated to the alternate path IBV_EVENT_PATH_MIG_ERR A connection failed to migrate to the alternate path IBV_EVENT_QP_LAST_WQE_REACHED Last WQE Reached on a QP associated with an SRQ CQ events: IBV_EVENT_CQ_ERR CQ is in error (CQ overrun) SRQ events: IBV_EVENT_SRQ_ERR Error occurred on an SRQ IBV_EVENT_SRQ_LIMIT_REACHED SRQ limit was reached Port events: IBV_EVENT_PORT_ACTIVE Link became active on a port IBV_EVENT_PORT_ERR Link became unavailable on a port IBV_EVENT_LID_CHANGE LID was changed on a port IBV_EVENT_PKEY_CHANGE P_Key table was changed on a port IBV_EVENT_SM_CHANGE SM was changed on a port IBV_EVENT_CLIENT_REREGISTER SM sent a CLIENT_REREGISTER request to a port IBV_EVENT_GID_CHANGE GID table was changed on a port CA events: IBV_EVENT_DEVICE_FATAL CA is in FATAL state ibv_ack_async_event() acknowledge the async event event. RETURN VALUE
ibv_get_async_event() returns 0 on success, and -1 on error. ibv_ack_async_event() returns no value. NOTES
All async events that ibv_get_async_event() returns must be acknowledged using ibv_ack_async_event(). To avoid races, destroying an object (CQ, SRQ or QP) will wait for all affiliated events for the object to be acknowledged; this avoids an application retrieving an affiliated event after the corresponding object has already been destroyed. ibv_get_async_event() is a blocking function. If multiple threads call this function simultaneously, then when an async event occurs, only one thread will receive it, and it is not possible to predict which thread will receive it. EXAMPLES
The following code example demonstrates one possible way to work with async events in non-blocking mode. It performs the following steps: 1. Set the async events queue work mode to be non-blocked 2. Poll the queue until it has an async event 3. Get the async event and ack it /* change the blocking mode of the async event queue */ flags = fcntl(ctx->async_fd, F_GETFL); rc = fcntl(ctx->async_fd, F_SETFL, flags | O_NONBLOCK); if (rc < 0) { fprintf(stderr, "Failed to change file descriptor of async event queue "); return 1; } /* * poll the queue until it has an event and sleep ms_timeout * milliseconds between any iteration */ my_pollfd.fd = ctx->async_fd; my_pollfd.events = POLLIN; my_pollfd.revents = 0; do { rc = poll(&my_pollfd, 1, ms_timeout); } while (rc == 0); if (rc < 0) { fprintf(stderr, "poll failed "); return 1; } /* Get the async event */ if (ibv_get_async_event(ctx, &async_event)) { fprintf(stderr, "Failed to get async_event "); return 1; } /* Ack the event */ ibv_ack_async_event(&async_event); SEE ALSO
ibv_open_device(3) AUTHORS
Dotan Barak <dotanba@gmail.com> libibverbs 2006-10-31 IBV_GET_ASYNC_EVENT(3)
All times are GMT -4. The time now is 12:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy