Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TCPSocketServer.h 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (C) 2012 mbed.org, MIT License
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  4. * and associated documentation files (the "Software"), to deal in the Software without restriction,
  5. * including without limitation the rights to use, copy, modify, merge, publish, distribute,
  6. * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
  7. * furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or
  10. * substantial portions of the Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  13. * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. */
  18. #ifndef TCPSOCKETSERVER_H
  19. #define TCPSOCKETSERVER_H
  20. #include "Socket/Socket.h"
  21. #include "TCPSocketConnection.h"
  22. /** TCP Server.
  23. */
  24. class TCPSocketServer : public Socket {
  25. public:
  26. /** Instantiate a TCP Server.
  27. */
  28. TCPSocketServer();
  29. /** Bind a socket to a specific port.
  30. \param port The port to listen for incoming connections on.
  31. \return 0 on success, -1 on failure.
  32. */
  33. int bind(int port);
  34. /** Start listening for incoming connections.
  35. \param backlog number of pending connections that can be queued up at any
  36. one time [Default: 1].
  37. \return 0 on success, -1 on failure.
  38. */
  39. int listen(int backlog=1);
  40. /** Accept a new connection.
  41. \param connection A TCPSocketConnection instance that will handle the incoming connection.
  42. \return 0 on success, -1 on failure.
  43. */
  44. int accept(TCPSocketConnection& connection);
  45. };
  46. #endif