NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

Committer:
bridadan
Date:
Tue May 19 17:40:28 2015 +0000
Revision:
2:ce08986b18b5
Parent:
1:291a9d61e58a
Child:
7:b147c08301be
Added some SocketInterface functions and docs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:d35446f60233 1 /* SocketInterface Base Class
sam_grove 0:d35446f60233 2 * Copyright (c) 2015 ARM Limited
sam_grove 0:d35446f60233 3 *
sam_grove 0:d35446f60233 4 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 0:d35446f60233 5 * you may not use this file except in compliance with the License.
sam_grove 0:d35446f60233 6 * You may obtain a copy of the License at
sam_grove 0:d35446f60233 7 *
sam_grove 0:d35446f60233 8 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 0:d35446f60233 9 *
sam_grove 0:d35446f60233 10 * Unless required by applicable law or agreed to in writing, software
sam_grove 0:d35446f60233 11 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 0:d35446f60233 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 0:d35446f60233 13 * See the License for the specific language governing permissions and
sam_grove 0:d35446f60233 14 * limitations under the License.
sam_grove 0:d35446f60233 15 */
sam_grove 0:d35446f60233 16
bridadan 1:291a9d61e58a 17 #ifndef SOCKETINTERFACE_H
bridadan 1:291a9d61e58a 18 #define SOCKETINTERFACE_H
bridadan 2:ce08986b18b5 19
bridadan 2:ce08986b18b5 20 /** SocketInterface class.
bridadan 2:ce08986b18b5 21 * This is a common interface that is shared between all sockets that connect
bridadan 2:ce08986b18b5 22 * using the NetworkInterface.
bridadan 2:ce08986b18b5 23 */
bridadan 1:291a9d61e58a 24 class SocketInterface {
bridadan 1:291a9d61e58a 25
bridadan 1:291a9d61e58a 26 public:
bridadan 2:ce08986b18b5 27 /**
bridadan 2:ce08986b18b5 28 * This enum defines the possible socket protocol families.
bridadan 2:ce08986b18b5 29 */
bridadan 2:ce08986b18b5 30 enum ProtocolFamily {
bridadan 2:ce08986b18b5 31 AF_INET, /**< IPv4 */
bridadan 2:ce08986b18b5 32 AF_INET6, /**< IPV6 */
bridadan 2:ce08986b18b5 33 AF_UNIX /**< Local socket (using a file) */
bridadan 2:ce08986b18b5 34 };
bridadan 2:ce08986b18b5 35
bridadan 2:ce08986b18b5 36 /**
bridadan 2:ce08986b18b5 37 * This enum defines the possible socket types.
bridadan 2:ce08986b18b5 38 */
bridadan 2:ce08986b18b5 39 enum SockType {
bridadan 2:ce08986b18b5 40 SOCK_STREAM, /**< Stream socket, generally used for TCP */
bridadan 2:ce08986b18b5 41 SOCK_DGRAM, /**< Datagram socket, generally used for UDP */
bridadan 2:ce08986b18b5 42 SOCK_SEQPACKET, /**< Reliable sequenced packet service */
bridadan 2:ce08986b18b5 43 SOCK_RAW /**< Raw protocols atop the network layer */
bridadan 2:ce08986b18b5 44 };
bridadan 1:291a9d61e58a 45
bridadan 2:ce08986b18b5 46 /**
bridadan 2:ce08986b18b5 47 * Configure the socket's protocol and type.
bridadan 2:ce08986b18b5 48 *
bridadan 2:ce08986b18b5 49 * @param protocol The protocol to use.
bridadan 2:ce08986b18b5 50 * @param type The type of socket to use.
bridadan 2:ce08986b18b5 51 */
bridadan 2:ce08986b18b5 52 virtual int config(ProtocolFamily protocol, SockType type) = 0;
bridadan 2:ce08986b18b5 53
bridadan 2:ce08986b18b5 54 /**
bridadan 2:ce08986b18b5 55 * Set blocking or non-blocking mode of the socket and a timeout on
bridadan 2:ce08986b18b5 56 * blocking socket operations.
bridadan 2:ce08986b18b5 57 *
bridadan 2:ce08986b18b5 58 * @param blocking true for blocking mode, false for non-blocking mode.
bridadan 2:ce08986b18b5 59 * @param timeout timeout in ms [Default: (1500)ms].
bridadan 2:ce08986b18b5 60 */
bridadan 2:ce08986b18b5 61 virtual void setBlocking(bool blocking, unsigned int timeout=1500) = 0;
bridadan 2:ce08986b18b5 62
bridadan 2:ce08986b18b5 63 /*
bridadan 2:ce08986b18b5 64 "options" functions here? Not familiar with this, need to discuss
bridadan 2:ce08986b18b5 65 */
bridadan 2:ce08986b18b5 66
bridadan 2:ce08986b18b5 67 /**
bridadan 2:ce08986b18b5 68 * Close the socket
bridadan 2:ce08986b18b5 69 */
bridadan 2:ce08986b18b5 70 virtual void close();
bridadan 1:291a9d61e58a 71
bridadan 1:291a9d61e58a 72 };
bridadan 1:291a9d61e58a 73
bridadan 1:291a9d61e58a 74 #endif
sam_grove 0:d35446f60233 75