Php Socket Error 11 Resource Temporarily Unavailable
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting resource temporarily unavailable socket recv ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join resource temporarily unavailable socket read the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a resource temporarily unavailable recvfrom minute: Sign up What can cause a “Resource temporarily unavailable” on sock send() command up vote 28 down vote favorite 6 What can cause a Resource temporarily unavailable error on a socket send() command? The socket is setup as AF_UNIX, SOCK_STREAM.
Errno 11 Resource Temporarily Unavailable Python
It works most of the time, but occasionally gets this error. The receiving end of the socket appears to be working properly. I know this isn't very detailed, but I'm just looking for general ideas. Thanks! c linux sockets unix share|improve this question edited Jan 17 '13 at 9:40 Ashwini Chaudhary 132k20199276 asked Jan 17 '13 at 0:49 giroy 73841634 Is this related? stackoverflow.com/questions/5737493/… –paddy Jan 17 '13 at 0:52 2 Are you setting your socket to O_NONBLOCK ? resource temporarily unavailable read –Deepankar Bajpeyi Jan 17 '13 at 0:57 I don't think it is related to that post. My sockets are SOCK_STREAM which I believe are blocking which is what I want. –giroy Jan 17 '13 at 0:59 2 Whether a stream is blocking or non-blocking is independent of whether it's SOCK_STREAM or SOCK_DGRAM. The answer there is relevant. –Barmar Jan 17 '13 at 1:33 add a comment| 2 Answers 2 active oldest votes up vote 35 down vote accepted "Resource temporarily unavailable" is the error message corresponding to EAGAIN, which means that the operation would have blocked but nonblocking operation was requested. For send(), that could be due to any of: explicitly marking the file descriptor as nonblocking with fcntl(); or passing the MSG_DONTWAIT flag to send(); or setting a send timeout with the SO_SNDTIMEO socket option. share|improve this answer answered Jan 17 '13 at 1:21 caf 156k14193325 The cause of my problem was setting the send timeout. Thank you for you help! –giroy Jan 17 '13 at 22:58 add a comment| up vote 17 down vote That's because you're using a non-blocking socket and the output buffer is full. From the send() man page When the message does not fit into the send buffer of the socket, send() normally blocks, unless the socket has been placed in non-block- ing I/O mode. In non-blocking mode it would return EAGAIN in this case. EAGAIN is the error code tied to "Resource tem
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more socket error resource temporarily unavailable python about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users
Resource Temporarily Unavailable Linux
Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping
Resource Temporarily Unavailable Errno
each other. Join them; it only takes a minute: Sign up sendto : Resource temporarily unavailable (errno 11) up vote 4 down vote favorite 2 I am having a problem with sendto. I have a receiver who receives http://stackoverflow.com/questions/14370489/what-can-cause-a-resource-temporarily-unavailable-on-sock-send-command UPD packets with recvfrom and then replies to the sender using sendto. Unfortunately, I am getting errno 11 (Resource temporarily unavailable). I am using two sockets. The first packet is actually sent but not the ones afterwards: sendto :: Success error: 0. sendto :: Resource temporarily unavailable error: 11. sendto :: Resource temporarily unavailable ... This is an extract of my code: int sockfd, sockSend; if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) perror("socket"); if ((sockSend = http://stackoverflow.com/questions/5737493/sendto-resource-temporarily-unavailable-errno-11 socket(AF_INET, SOCK_DGRAM, 0)) < 0) perror("socket"); if (fcntl(sockfd, F_SETOWN, getpid()) < 0) { perror("fcntl"); } if (fcntl(sockfd, F_SETFL, O_RDONLY | O_NONBLOCK | FASYNC) < 0) { perror("fcntl"); } if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("bind"); And in a SIGIO handler: len = sizeof(recv_addr); char buffer[payload]; bzero(buffer, payload); n = recvfrom(sockfd, buffer, payload, MSG_DONTWAIT, (struct sockaddr *)&recv_addr, &len); while (n > 0) { sprintf(response, "%d\n%d\n%d\n", items, target_buf, pb_sp); sendto(sockSend, response, strlen(response), 0, (struct sockaddr *) &recv_addr, sizeof(recv_addr)); // sleep(1); perror("sendto :"); printf("error: %d.\n", errno); } Could this issue come because the port is still hot, and I need to wait before reusing it? I've tried to change port but it hasn't helped. Update: If the sleep(1) is commented out, then the packets actually get send! Thanks a lot for your help. c sockets udp sendto share|improve this question edited Apr 21 '11 at 0:03 asked Apr 20 '11 at 22:44 Jary 23114 Are you using two sockets with the same port? If so, what is the reason? –penguin359 Apr 20 '11 at 22:47 Perhaps SO_REUSEADDR would help. Or you could just keep the port open rather than opening and closing it, or use a new randomly assigned port number each time if that's feasible. –R.. Apr 20 '11 at 22:52 I have added more code. I have 2 sockets but
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported http://php.net/manual/en/function.socket-recv.php Protocols and Wrappers Security Introduction General considerations Installed as CGI binary Installed as an Apache module Session Security Filesystem Security Database Security Error Reporting http://qiita.com/kuni-nakaji/items/38d46b09f3bff1d1a973 Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads resource temporarily Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System resource temporarily unavailable Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation GUI Extensions Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box socket_recvfrom » « socket_read PHP Manual Function Reference Other Services Sockets Socket Functions Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug socket_recv (PHP 4 >= 4.1.0, PHP 5, PHP 7)socket_recv — Receives data from a connected socket Description
攻撃的または迷惑な内容を含んでいます 不適切な内容を含んでいます 送信55ストック0コメントストックストック済み解除 課題 nginxでsocket(pathname)を使用して通信効率をあげようとしてみた。通信量が増えてきた所でResource temporarily unavailableということでリソース不足で怒られるようになった。 2015/11/10 23:02:27 [error] 1298#0: *296601104 connect() to unix:///tmp/sample.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 192.168.1.2, server: hoge.com, request: "POST /sample.php?p=xx_xx&_=1447164211618 HTTP/1.1", upstream: "uwsgi://unix:///tmp/sample.sock:", host: "hoge.com", referrer: "https://www.foo.com/xxx/yyy/" 設定 対象になりそうな部分だけみてみると、 nginx.conf worker_processes 2; worker_rlimit_nofile 65536; events { worker_connections 1024; } location / { # uWSGI application include uwsgi_params; uwsgi_pass unix:///tmp/sample.sock; uwsgi_connect_timeout 2s; uwsgi_read_timeout 2s; } 思い当たりそうなところを調べてみる うーん、リソース不足...CPUもメモリもまだ余裕がある ulimitか? # ulimit -n 1024 多くは無いけどw socket fileは大量に出来るわけでも無いのでなんか違う気がする。 ファイルディスクリプタが問題ならtoo many open filesのほうが出てきそう。 Apacheの時は256くらいのプロセス数でやったことを考えると、Nginxなら2048くらいのコネクションが精一杯か...サーバ増やすのも対して面倒じゃなくなったのでスケールアウトなんてことも そんなわきゃない ネットワーク状態遷移とNginxへ通信が到達するところまでを調べてみた。 kernelのところに影響があったのか! 見てみる # sysctl net.core.somaxconn net.core.somaxconn = 128 128??? すくなっ!? nginxで2048を受けること考えると倍くらいでも良いのかもしれないけど、大きめに設定。この値はnet.core.somaxconnより大きかった場合、net.core.somaxconnの値を優先するようです。 (環境に合わせて数値は変更してください) /etc/sysctl.conf --(snip)-- net.ipv4.tcp_max_syn_backlog = 20480 net.core.somaxconn=20480 # s