blob: 0be5361bf77e66b14e7c780ebae8c5da2d716448 [file] [log] [blame]
David Ghandehari9e5b5872016-07-28 09:50:04 -07001// Copyright 2016 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "starboard/shared/posix/set_non_blocking_internal.h"
16
17#include <fcntl.h>
18
19namespace starboard {
20namespace shared {
21namespace posix {
22
23bool SetNonBlocking(int socket_fd) {
24 int flags = fcntl(socket_fd, F_GETFL, 0);
25 return !(flags < 0 || fcntl(socket_fd, F_SETFL, flags | O_NONBLOCK) == -1);
26}
27
28} // namespace posix
29} // namespace shared
30} // namespace starboard