{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/2493","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/2493/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/2493/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/2493/events","html_url":"https://github.com/ARMmbed/mbed-os/issues/2493","id":171946812,"number":2493,"title":"TCPSocket send() in one thread blocked by recv() in another","user":{"login":"pythontech","id":1310165,"avatar_url":"https://avatars.githubusercontent.com/u/1310165?v=3","gravatar_id":"","url":"https://api.github.com/users/pythontech","html_url":"https://github.com/pythontech","followers_url":"https://api.github.com/users/pythontech/followers","following_url":"https://api.github.com/users/pythontech/following{/other_user}","gists_url":"https://api.github.com/users/pythontech/gists{/gist_id}","starred_url":"https://api.github.com/users/pythontech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pythontech/subscriptions","organizations_url":"https://api.github.com/users/pythontech/orgs","repos_url":"https://api.github.com/users/pythontech/repos","events_url":"https://api.github.com/users/pythontech/events{/privacy}","received_events_url":"https://api.github.com/users/pythontech/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-18T16:40:34Z","updated_at":"2016-08-20T08:04:47Z","closed_at":null,"body":"When one thread is blocked in a recv() call on a TCPSocket, a send() call to the same socket in another thread appears to block until the recv() succeeds.\r\n\r\nI have created a [test program](https://developer.mbed.org/users/infinnovation/code/sendrecv/) which demonstrates this.  The synopsis is:\r\n\r\n- Create a TCPServer instance and accept() a TCPSocket connection.\r\n- Spawn a thread which loops doing a recv() and reporting each byte on the serial console\r\n- In the main thread, send() a small packet to the client at regular intervals.\r\n\r\nWhat I expect is that the threads operate independently: the regular send() calls complete regardless of whether any data is recv()ed in the ancillary thread.\r\n\r\nWhat I see is that each send() call is blocked until data is sent from the client and recv()ed.\r\n\r\nAs an example run, I telnet to the FRDM-K64F; wait several seconds; type \"hi\"; wait several more seconds; type \"foo\".\r\n\r\nAt the telnet end, what I see is (with my input echoed):\r\n```\r\nhi\r\ntick\r\nfoo\r\ntick\r\n```\r\n\r\nAt the FRDM end, what I see is this:\r\n```\r\n== sendrecv ==\r\nip 10.212.1.154\r\naccepted connection\r\ntick...\r\nrecv 68=h\r\n...sent\r\nrecv 69=i\r\nrecv 0d=?\r\nrecv 0a=?\r\ntick...\r\nrecv 66=f\r\n...sent\r\nrecv 6f=o\r\nrecv 6f=o\r\nrecv 0d=?\r\nrecv 0a=?\r\ntick...\r\n```\r\n\r\nA similar pattern of operation worked as I expected with mbed 2 and the EthernetInterface library.\r\n\r\nThis issue may be related to #2426 "},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments/241186255","html_url":"https://github.com/ARMmbed/mbed-os/issues/2493#issuecomment-241186255","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/2493","id":241186255,"user":{"login":"infinnovation","id":9962949,"avatar_url":"https://avatars.githubusercontent.com/u/9962949?v=3","gravatar_id":"","url":"https://api.github.com/users/infinnovation","html_url":"https://github.com/infinnovation","followers_url":"https://api.github.com/users/infinnovation/followers","following_url":"https://api.github.com/users/infinnovation/following{/other_user}","gists_url":"https://api.github.com/users/infinnovation/gists{/gist_id}","starred_url":"https://api.github.com/users/infinnovation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infinnovation/subscriptions","organizations_url":"https://api.github.com/users/infinnovation/orgs","repos_url":"https://api.github.com/users/infinnovation/repos","events_url":"https://api.github.com/users/infinnovation/events{/privacy}","received_events_url":"https://api.github.com/users/infinnovation/received_events","type":"User","site_admin":false},"created_at":"2016-08-20T08:04:47Z","updated_at":"2016-08-20T08:04:47Z","body":"Many thanks for the fix.\r\n\r\n(I inadvertently posted the issue from a different account, not that it matters)"}}
{"actor":{"display_login":"infinnovation"}}