How to implement WebSocket Client in C
-
Hi All, I have to hit a WebSocket server and have to maintain the connection alive. Please share some article about implementing a WebSocket Client application in C. Thanks All.
Do your Duty and Don't expect the Result
-
Hi All, I have to hit a WebSocket server and have to maintain the connection alive. Please share some article about implementing a WebSocket Client application in C. Thanks All.
Do your Duty and Don't expect the Result
For a socket client in Windows you basically need to call the following functions in order - WSAStartup[^] - Initialize winsock. socket[^] - Create the socket specifying the required protocol like TCP, UDP etc. connect[^] - Connect the previously created socket to the specified server. After this step the connection is ready. To communicate with the server you can use the following functions - send[^]/sendto[^] - Send a stream of bytes to the server. recv[^]/recvfrom[^] - Receive a stream of bytes from the server. To tear down the connection the following functions must be called - closesocket[^] - Disconnect WSACleanup[^] - Cleanup winsock.
«_Superman_» I love work. It gives me something to d
-
For a socket client in Windows you basically need to call the following functions in order - WSAStartup[^] - Initialize winsock. socket[^] - Create the socket specifying the required protocol like TCP, UDP etc. connect[^] - Connect the previously created socket to the specified server. After this step the connection is ready. To communicate with the server you can use the following functions - send[^]/sendto[^] - Send a stream of bytes to the server. recv[^]/recvfrom[^] - Receive a stream of bytes from the server. To tear down the connection the following functions must be called - closesocket[^] - Disconnect WSACleanup[^] - Cleanup winsock.
«_Superman_» I love work. It gives me something to d
Thanks for the reply.. but i'm not looking for normal Socket implementation. Any way i got little help here http://en.wikipedia.org/wiki/WebSockets[^]
Do your Duty and Don't expect the Result
-
Thanks for the reply.. but i'm not looking for normal Socket implementation. Any way i got little help here http://en.wikipedia.org/wiki/WebSockets[^]
Do your Duty and Don't expect the Result
-
The WebSocket protocol works on top of a normal TCP socket connection, so you must understand Winsock first before you can start implementing WebSockets.
Thanks for the reponses.. guess i'm not clear with my question.. I'm clear about the WinSocket APIs.. just need to know the WebSocket Handshake details.. I got the below header from Wikipedia & i want to know what are all the things are variable values in this header?
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00^n:ds[4U
As far as i know the /demo in first line, Host & Origin will change.. but exactly what will be the values? Will the values of Key1, Key2 & the last 8 byte values also change? I have to hit the server which has the format as ws://xxx.xxx.xxx.xxx:8181/websock Also is it possible to send any extra information in the above handshake header? if so what will be its format? Thanks Again.
Do your Duty and Don't expect the Result
-
Thanks for the reponses.. guess i'm not clear with my question.. I'm clear about the WinSocket APIs.. just need to know the WebSocket Handshake details.. I got the below header from Wikipedia & i want to know what are all the things are variable values in this header?
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00^n:ds[4U
As far as i know the /demo in first line, Host & Origin will change.. but exactly what will be the values? Will the values of Key1, Key2 & the last 8 byte values also change? I have to hit the server which has the format as ws://xxx.xxx.xxx.xxx:8181/websock Also is it possible to send any extra information in the above handshake header? if so what will be its format? Thanks Again.
Do your Duty and Don't expect the Result
-
Thanks for the reponses.. guess i'm not clear with my question.. I'm clear about the WinSocket APIs.. just need to know the WebSocket Handshake details.. I got the below header from Wikipedia & i want to know what are all the things are variable values in this header?
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00^n:ds[4U
As far as i know the /demo in first line, Host & Origin will change.. but exactly what will be the values? Will the values of Key1, Key2 & the last 8 byte values also change? I have to hit the server which has the format as ws://xxx.xxx.xxx.xxx:8181/websock Also is it possible to send any extra information in the above handshake header? if so what will be its format? Thanks Again.
Do your Duty and Don't expect the Result
Can websockets be implemented using CURL ? Also it seems that once the client receives "HTTP/1.1 101 WebSocket Protocol Handshake" it should just wait on recv or recvfrom. Am I correct ? If so, who closes the socket connection once all communication is done? The server or the client ? Thanks