Click here to Skip to main content
Rate this: bad
good
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
kavinsp269

1 solution

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

Solution 1

Hi,
 
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.
 

So:
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.
  Permalink  
Comments
kavinsp at 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)



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