Click here to Skip to main content
15,885,918 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What are the steps to develop websocket server implementation in c++??
Posted

1 solution

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.
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900