I recommend you use text mode, it makes it much easier to communicate with a web server. If you need to send binary data, you can setup a binary transfer, but initial communication and link setup will be done using strict ASCII text.
If you do not have too much binary data to send, you can use Base64 to convert the binary data into ASCII and back.
You cannot make a socket connection from a browser. Create a server with jServer and then communicate with ajax (regular http requests) or web sockets.