ap
Dependencies: DnsQuery
Dependents: WizFi310_TCP_Echo_Server_Example
Fork of NetworkSocketAPI by
SocketAddress.h@79:43a7e8c0d6cc, 2016-04-05 (annotated)
- Committer:
- Christopher Haster
- Date:
- Tue Apr 05 10:40:34 2016 -0500
- Revision:
- 79:43a7e8c0d6cc
- Parent:
- 78:0914f9b9b24b
- Child:
- 80:9c6673c93082
Added rough implementation of the API shim
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 |
75:dea0cdb42241 | 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 |
75:dea0cdb42241 | 7 | * |
Christopher Haster |
78:0914f9b9b24b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Christopher Haster |
75:dea0cdb42241 | 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 |
75:dea0cdb42241 | 15 | */ |
Christopher Haster |
78:0914f9b9b24b | 16 | |
Christopher Haster |
76:bbe51641f405 | 17 | #ifndef SOCKET_ADDRESS_H |
Christopher Haster |
76:bbe51641f405 | 18 | #define SOCKET_ADDRESS_H |
Christopher Haster |
75:dea0cdb42241 | 19 | |
Christopher Haster |
79:43a7e8c0d6cc | 20 | #include <stdint.h> |
Christopher Haster |
79:43a7e8c0d6cc | 21 | |
Christopher Haster |
75:dea0cdb42241 | 22 | /** |
Christopher Haster |
75:dea0cdb42241 | 23 | * A general socket address composed of the IP address and port |
Christopher Haster |
75:dea0cdb42241 | 24 | */ |
Christopher Haster |
75:dea0cdb42241 | 25 | class SocketAddress { |
Christopher Haster |
75:dea0cdb42241 | 26 | public: |
Christopher Haster |
79:43a7e8c0d6cc | 27 | /** SocketAddress construction |
Christopher Haster |
79:43a7e8c0d6cc | 28 | /param addr Null-terminated string representing the IP address |
Christopher Haster |
79:43a7e8c0d6cc | 29 | /param port 16-bit port |
Christopher Haster |
75:dea0cdb42241 | 30 | */ |
Christopher Haster |
76:bbe51641f405 | 31 | SocketAddress(const char *addr = 0, uint16_t port = 0); |
Christopher Haster |
76:bbe51641f405 | 32 | SocketAddress(const SocketAddress &); |
Christopher Haster |
75:dea0cdb42241 | 33 | |
Christopher Haster |
75:dea0cdb42241 | 34 | /** Set the IP address |
Christopher Haster |
79:43a7e8c0d6cc | 35 | \param addr Null-terminated string representing the IP address |
Christopher Haster |
75:dea0cdb42241 | 36 | */ |
Christopher Haster |
79:43a7e8c0d6cc | 37 | void set_ip_address(const char *addr); |
Christopher Haster |
75:dea0cdb42241 | 38 | |
Christopher Haster |
75:dea0cdb42241 | 39 | /** Set the port |
Christopher Haster |
75:dea0cdb42241 | 40 | \param port 16-bit port |
Christopher Haster |
75:dea0cdb42241 | 41 | */ |
Christopher Haster |
75:dea0cdb42241 | 42 | void set_port(uint16_t port); |
Christopher Haster |
75:dea0cdb42241 | 43 | |
Christopher Haster |
75:dea0cdb42241 | 44 | /** Get the IP address |
Christopher Haster |
75:dea0cdb42241 | 45 | \return The string representation of the IP Address |
Christopher Haster |
75:dea0cdb42241 | 46 | */ |
Christopher Haster |
79:43a7e8c0d6cc | 47 | const char *get_ip_address() const; |
Christopher Haster |
75:dea0cdb42241 | 48 | |
Christopher Haster |
75:dea0cdb42241 | 49 | /** Get the port |
Christopher Haster |
75:dea0cdb42241 | 50 | \return The 16-bit port |
Christopher Haster |
75:dea0cdb42241 | 51 | */ |
Christopher Haster |
79:43a7e8c0d6cc | 52 | uint16_t get_port(void) const; |
Christopher Haster |
79:43a7e8c0d6cc | 53 | |
Christopher Haster |
79:43a7e8c0d6cc | 54 | private: |
Christopher Haster |
79:43a7e8c0d6cc | 55 | char _ip_address[16]; |
Christopher Haster |
79:43a7e8c0d6cc | 56 | uint16_t _port; |
Christopher Haster |
75:dea0cdb42241 | 57 | }; |
Christopher Haster |
75:dea0cdb42241 | 58 | |
Christopher Haster |
75:dea0cdb42241 | 59 | #endif |