Example of AWS IoT connection and Web Dashboard thru STM32 Nucleo evaluation board and mbed OS.
Dependencies: X_NUCLEO_IKS01A1 mbed FP MQTTPacket DnsQuery ATParser
TCPServer.h
00001 /* TCPServer 00002 * Copyright (c) 2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef TCPSERVER_H 00018 #define TCPSERVER_H 00019 00020 #include "Socket.h" 00021 #include "TCPSocket.h" 00022 #include "NetworkStack.h" 00023 00024 /** TCP socket server 00025 */ 00026 class TCPServer : public Socket { 00027 public: 00028 /** Create an uninitialized socket 00029 * 00030 * Must call open to initialize the socket on a network stack. 00031 */ 00032 TCPServer(); 00033 00034 /** Create a socket on a network stack 00035 * 00036 * Creates and opens a socket on the specified network stack. 00037 * 00038 * @param iface Network stack as target for socket 00039 */ 00040 TCPServer(NetworkStack *iface); 00041 00042 /** Opens a socket 00043 * 00044 * Creates a network socket on the specified network stack. 00045 * Not needed if stack is passed to the socket's constructor. 00046 * 00047 * @param iface Network stack as target for socket 00048 * @return 0 on success, negative error code on failure 00049 */ 00050 virtual int open(NetworkStack *iface); 00051 00052 /** Listen for connections on a TCP socket 00053 * 00054 * Marks the socket as a passive socket that can be used to accept 00055 * incoming connections. 00056 * 00057 * @param backlog Number of pending connections that can be queued 00058 * simultaneously, defaults to 1 00059 * @return 0 on success, negative error code on failure 00060 */ 00061 int listen(int backlog = 1); 00062 00063 /** Accepts a connection on a TCP socket 00064 * 00065 * The server socket must be bound and set to listen for connections. 00066 * On a new connection, creates a network socket using the specified 00067 * socket instance. 00068 * 00069 * By default, accept blocks until data is sent. If socket is set to 00070 * non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned 00071 * immediately. 00072 * 00073 * @param socket TCPSocket instance that will handle the incoming connection. 00074 * @return 0 on success, negative error code on failure 00075 */ 00076 int accept(TCPSocket *connection); 00077 }; 00078 00079 #endif
Generated on Wed Jul 13 2022 20:28:49 by 1.7.2