Click here to Skip to main content
12,893,481 members (51,412 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++
What are the steps to develop websocket server implementation in c++??
Posted 20-Feb-13 20:18pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


This is quite easy. Actually, there are severela possibilities. Basicly:
1) Use low level functions - if you write your code well, it can we event portable between Windows and Linux.
2) Use some library - this solution can be (but doesnt have to be) portable.

If you want to use the firtst option you shell study function socket, bind, listen and accept. These functions aree usually called by a TCP server in order to start waiting and accepting connections. You will find pretty good examples how to use these function in the links above as well. BUT, be aware that HTTP protocol is a text protocol, and so you will have to parse and all possible HTTP-request and send all possible HTTP-responses in your code. And THAT will be really tedious to write !!!

Perhaps I would recommend to use some prepared library or API. If you are going to writ the server app for Windows, you might use WinInet API.

However, dont forget to make your server multithreaded, so that it can serve many client requests/connections at one time. This would require to create a thread for each incoming client connection. This thread would serve the client and then termionate. This is quite a difficult topic, if you are a beginer, but if you want to read about it, you can find some info good in MSDN documentation.

Best Regards,
J. K.
kavinsp 21-Feb-13 3:40am
Thanks, but what is the library used for mac ? and is there any specific port numbers used on mac for web socket

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100