Question

I am implementing websocket v07 server protocol in C/C++. It's pretty easy and I have almost coded it. Though I can't understand what mean numbers in first initial packet (not handshake)? Client uses "socket.io" framework. So client sends Date and server answer with another number. I think its something like checksum. Can anyone explain me please how to generate answer and what does it mean?

Examples:

client GET./socket.io/1/?t=1322647367092&jsonp=0

server 52 io.j[0]("1880965230667822746 :15:25:websocket,htmlfile,xhr-polling,jsonp-polling");

client GET./socket.io/1/?t=1322647141334&jsonp=0

server 52 io.j[0]("7826289221657265491 :15:25:websocket,htmlfile,xhr-polling,jsonp-polling");

1322647367092 - Date, server answer - 1880965230667822746

1322647141334 - Date, server answer - 7826289221657265491

My Packet ->

000000 48 54 54 50 2F 31 2E 31 | 20 32 30 30 20 4F 4B 0D     HTTP/1.1.200.OK.
000010 0A 43 6F 6E 74 65 6E 74 | 2D 54 79 70 65 3A 20 61     .Content-Type:.a
000020 70 70 6C 69 63 61 74 69 | 6F 6E 2F 6A 61 76 61 73     pplication/javas
000030 63 72 69 70 74 0D 0A 43 | 6F 6E 6E 65 63 74 69 6F     cript..Connectio
000040 6E 3A 20 6B 65 65 70 2D | 61 6C 69 76 65 0D 0A 54     n:.keep-alive..T
000050 72 61 6E 73 66 65 72 2D | 45 6E 63 6F 64 69 6E 67     ransfer-Encoding
000060 3A 20 63 68 75 6E 6B 65 | 64 0D 0A 0D 0A 35 30 0D     :.chunked....50.
000070 0A 69 6F 2E 6A 5B 30 5D | 28 22 32 37 38 38 39 39     .io.j[0]("278899
000080 38 30 38 38 32 36 32 34 | 38 38 30 3A 31 35 3A 32     80882624880:15:2
000090 35 3A 77 65 62 73 6F 63 | 6B 65 74 2C 68 74 6D 6C     5:websocket,html
0000A0 66 69 6C 65 2C 78 68 72 | 2D 70 6F 6C 6C 69 6E 67     file,xhr-polling
0000B0 2C 6A 73 6F 6E 70 2D 70 | 6F 6C 6C 69 6E 67 22 29     ,jsonp-polling")
0000C0 3B 0D 0A 30 0D 0A 0D 0A                               ;..0....

Original Packet ->

000000 48 54 54 50 2F 31 2E 31 | 20 32 30 30 20 4F 4B 0D     HTTP/1.1.200.OK.
000010 0A 43 6F 6E 74 65 6E 74 | 2D 54 79 70 65 3A 20 61     .Content-Type:.a
000020 70 70 6C 69 63 61 74 69 | 6F 6E 2F 6A 61 76 61 73     pplication/javas
000030 63 72 69 70 74 0D 0A 43 | 6F 6E 6E 65 63 74 69 6F     cript..Connectio
000040 6E 3A 20 6B 65 65 70 2D | 61 6C 69 76 65 0D 0A 54     n:.keep-alive..T
000050 72 61 6E 73 66 65 72 2D | 45 6E 63 6F 64 69 6E 67     ransfer-Encoding
000060 3A 20 63 68 75 6E 6B 65 | 64 0D 0A 0D 0A 35 30 0D     :.chunked....50.
000070 0A 69 6F 2E 6A 5B 30 5D | 28 22 33 38 34 35 36 31     .io.j[0]("384561
000080 33 32 31 33 36 32 32 39 | 34 30 37 3A 31 35 3A 32     32136229407:15:2
000090 35 3A 77 65 62 73 6F 63 | 6B 65 74 2C 68 74 6D 6C     5:websocket,html
0000A0 66 69 6C 65 2C 78 68 72 | 2D 70 6F 6C 6C 69 6E 67     file,xhr-polling
0000B0 2C 6A 73 6F 6E 70 2D 70 | 6F 6C 6C 69 6E 67 22 29     ,jsonp-polling")
0000C0 3B 0D 0A 30 0D 0A 0D 0A                               ;..0....
Was it helpful?

Solution

It is a "session ID" according to the socket.io protocol specification:

The body of the response should contain the session id (sid) given to the client, followed by the heartbeat timeout, the connection closing timeout, and the list of supported transports separated by :

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top