- To check using the command line if a server is running on a certain port:
nc -zv localhost 80- To send a packet of information to the server using the netcat command use:
echo -n “Ground Control For Major Tom” | nc localhost 8080- Send curl command to mimic websocket handshake request (notice the -v command to see the header responses):
curl --include -v --no-buffer --header "Connection: Upgrade" --header "Upgrade: websocket" --header "Host: example.com:80" --header "Origin: http://example.com:80" --header "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" --header "Sec-WebSocket-Version: 13" http://localhost:8080-
byteis the basic unit of data used to store and represent information. A byte is a group of 8 bits, which can represent 256 different values (from 0 to 255). When dealing with network communication, data is typically read and written as raw bytes, regardless of the type of data it represents (text, numbers, etc.). -
bitis the most basic unit of data in computing and can hold one of two possible values:0or1. 8bitsyou can represent 256 (2^8) unique numbers which correspond to characters in theASCIIcharacter set. Ex: the byte01001000representsHinASCII.
- Example convert 72 to binary
-
Binary place values are:
128 64 32 16 8 4 2 1 -
Start with the highest place value
128. Since 72 is less than 128, put a0. -
Compare 72 with
64. Since 72 is greater than 64, put a1and and subtract 64 from 72, leaving 8. -
Continue until the end.
Therefore 72 in binary is 01001000
-
Suppose we have a byte array like the following:
[72, 101, 108, 108, 111]
-
Do a look up in the
ASCIItable to determine which character the number coresponds to.