Establishing a websocket connection with another server

366 Views Asked by At

I'm working on embedding Mongoose into an application, and I need to be able to have the app connect to a server when it starts up. How can I do this? On GitHub, I see examples for receiving connections, but none on how to initialize a connection with another one. Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

Mongoose is a web server. It is designed to accept incoming connections, not make outgoing ones.

If you want to make outgoing connections, the way forward will depend on what you are connecting to and what protocol(s) it may use.

If you want to make outgoing http or https connections, you could use libcurl.

If some other protocol you may be able to find an appropriate library. Or, you can use operating system layer socket APIs to make your own connection, and implement whatever protocol is required on top of that. Here is an example for Linux, for example.