Arduino Socket Similar to Windows Socket with Events

An equivalent of windows socket in ESP(MCU) arduino environment. This library is an event driven with similar experience to windows socket.

This library can also be implemented as a client or server depending on the use case of the user. The server socket can handle multiple client connection depending on the HAC_SERVER_MAX_SOCKET_CLIENTS definition(Note: Default value is 5 simultaneous client, it can be increase further but make sure to manage the memory it utilized for each session).

  • Events supported as a Server Socket:
  1. On Data Arrival
  • Event raised when server receive a stream of data packet from the remote end client.
  1. On New Connection
  • Event raised when server accepted a new connection from the remote end client.
  1. On Data Sent
  • Event raised when server successfully send a data packet to the remote end client.
  1. On Socket Closed
  • Event raised when server close or remote end client close the active connection.
  1. On Socket Error
  • Event raised when server encounter a socket error on the existing connection to the remote end client.
  1. On Poll
  • Event raised when server remote end client active connection is actively polling.

  • Events supported as a Client Socket:

  1. On Data Arrival
  • Event raised when client receive a stream of data packet from the remote end server.
  1. On Connected
  • Event raised when client established a connection to remore end server.
  1. On Data Sent
  • Event raised when client successfully send a data packet to the remote end server.
  1. On Socket Closed
  • Event raised when server close or remote end client close the active connection.
  1. On Socket Error
  • Event raised when client encounter a socket error on the existing connection to the remote end server.
  1. On Poll
  • Event raised when client active connection is actively polling from the remote end server.

How is this different from the existing websockets library?

you made the library you describe or you seek such library?

@cedarlakeinstruments websockes are a different thing than TCP sockets

Yes, I'm aware of that. However as far as I recall, arduino websockets implementations have all of the above already, so I assumed that behavior was already present in the underlying sockets.

Websockets are running on http whereas sockets running on raw tcp/udp protocols. Websockets used for web application that requires a constant connection with the webclient while socket use for all type of application that use the tcp or udp protocols. They work almost the same but they are different on implementation. On top of that, since http is running with tcp sockets it means that websocket is also running from the raw sockets.

The purpose of this library though is to utilized the raw socket for any use case applicable such as chat between mcu or transfer of information between mcu using custom protocols. This library can be use as well if you want to build your own mcu webserver(which is already existing) or a proxy server to pass from one mcu to another mcu on which connected to different network wifi station.

in Arduino networking libraries Client class is used where TCP sockets in C are used.
WiFiClient or EthernetClient

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.