NetworkSocketAPI
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Socket.h@78:0914f9b9b24b, 2016-04-05 (annotated)
- Committer:
- Christopher Haster
- Date:
- Tue Apr 05 09:20:32 2016 -0500
- Revision:
- 78:0914f9b9b24b
- Parent:
- 77:b66a6984ed2d
- Child:
- 79:43a7e8c0d6cc
Dragged over license from nsapi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Christopher Haster |
78:0914f9b9b24b | 1 | /* Socket |
Christopher Haster |
78:0914f9b9b24b | 2 | * Copyright (c) 2015 ARM Limited |
Christopher Haster |
72:6a8b52ee83ed | 3 | * |
Christopher Haster |
78:0914f9b9b24b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Christopher Haster |
78:0914f9b9b24b | 5 | * you may not use this file except in compliance with the License. |
Christopher Haster |
78:0914f9b9b24b | 6 | * You may obtain a copy of the License at |
Christopher Haster |
72:6a8b52ee83ed | 7 | * |
Christopher Haster |
78:0914f9b9b24b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Christopher Haster |
72:6a8b52ee83ed | 9 | * |
Christopher Haster |
78:0914f9b9b24b | 10 | * Unless required by applicable law or agreed to in writing, software |
Christopher Haster |
78:0914f9b9b24b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Christopher Haster |
78:0914f9b9b24b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Christopher Haster |
78:0914f9b9b24b | 13 | * See the License for the specific language governing permissions and |
Christopher Haster |
78:0914f9b9b24b | 14 | * limitations under the License. |
Christopher Haster |
72:6a8b52ee83ed | 15 | */ |
Christopher Haster |
78:0914f9b9b24b | 16 | |
Christopher Haster |
72:6a8b52ee83ed | 17 | #ifndef SOCKET_H |
Christopher Haster |
72:6a8b52ee83ed | 18 | #define SOCKET_H |
Christopher Haster |
72:6a8b52ee83ed | 19 | |
Christopher Haster |
74:ef2470ca328b | 20 | |
Christopher Haster |
72:6a8b52ee83ed | 21 | /** Abstract socket class |
Christopher Haster |
74:ef2470ca328b | 22 | */ |
Christopher Haster |
72:6a8b52ee83ed | 23 | class Socket { |
Christopher Haster |
72:6a8b52ee83ed | 24 | public: |
Christopher Haster |
72:6a8b52ee83ed | 25 | /** Socket lifetime |
Christopher Haster |
72:6a8b52ee83ed | 26 | */ |
Christopher Haster |
72:6a8b52ee83ed | 27 | Socket(); |
Christopher Haster |
72:6a8b52ee83ed | 28 | ~Socket(); |
Christopher Haster |
72:6a8b52ee83ed | 29 | |
Christopher Haster |
72:6a8b52ee83ed | 30 | /** Set blocking or non-blocking mode of the socket |
Christopher Haster |
72:6a8b52ee83ed | 31 | \param blocking true for blocking mode, false for non-blocking mode. |
Christopher Haster |
72:6a8b52ee83ed | 32 | */ |
Christopher Haster |
72:6a8b52ee83ed | 33 | void set_blocking(bool blocking); |
Christopher Haster |
72:6a8b52ee83ed | 34 | |
Christopher Haster |
74:ef2470ca328b | 35 | /** Set timeout on a socket operation if blocking behaviour is enabled |
Christopher Haster |
72:6a8b52ee83ed | 36 | \param timeout timeout in ms |
Christopher Haster |
72:6a8b52ee83ed | 37 | */ |
Christopher Haster |
72:6a8b52ee83ed | 38 | void set_timeout(unsigned int timeout); |
Christopher Haster |
72:6a8b52ee83ed | 39 | |
Christopher Haster |
72:6a8b52ee83ed | 40 | /** Set socket options |
Christopher Haster |
76:bbe51641f405 | 41 | \param optname Option ID |
Christopher Haster |
76:bbe51641f405 | 42 | \param optval Option value |
Christopher Haster |
76:bbe51641f405 | 43 | \param optlen Length of the option value |
Christopher Haster |
76:bbe51641f405 | 44 | \return 0 on success, negative on failure |
Christopher Haster |
72:6a8b52ee83ed | 45 | */ |
Christopher Haster |
74:ef2470ca328b | 46 | int set_option(int optname, const void *optval, unsigned int optlen); |
Christopher Haster |
72:6a8b52ee83ed | 47 | |
Christopher Haster |
72:6a8b52ee83ed | 48 | /** Get socket options |
Christopher Haster |
76:bbe51641f405 | 49 | \param optname Option ID |
Christopher Haster |
76:bbe51641f405 | 50 | \param optval Buffer pointer where to write the option value |
Christopher Haster |
76:bbe51641f405 | 51 | \param optlen Length of the option value |
Christopher Haster |
76:bbe51641f405 | 52 | \return 0 on success, negative on failure |
Christopher Haster |
72:6a8b52ee83ed | 53 | */ |
Christopher Haster |
74:ef2470ca328b | 54 | int get_option(int optname, void *optval, unsigned int *optlen); |
Christopher Haster |
72:6a8b52ee83ed | 55 | |
Christopher Haster |
72:6a8b52ee83ed | 56 | /** Close the socket |
Christopher Haster |
72:6a8b52ee83ed | 57 | \param shutdown free the left-over data in message queues |
Christopher Haster |
72:6a8b52ee83ed | 58 | */ |
Christopher Haster |
72:6a8b52ee83ed | 59 | int close(bool shutdown=true); |
Christopher Haster |
72:6a8b52ee83ed | 60 | }; |
Christopher Haster |
72:6a8b52ee83ed | 61 | |
Christopher Haster |
72:6a8b52ee83ed | 62 | #endif |