Python Forum

Full Version: socket library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to python socket.py and while learning this library I got a question, answer to which I coundn't find in any resource.
I know that there is a number of ways to pass binary to sent() method. For example:
socket.send(b"Hello world")
or
socket.send("Hello world".encode())
But is there a way to pass string as arguement to send() without converting it to binary?
(Mar-04-2024, 03:51 PM)Kate Wrote: [ -> ]But is there a way to pass string as arguement to send() without converting it to binary?
As far as I know, the answer is no, but this is not a limitation. In the same way, when one writes a string in a file it is necessarily converted to binary at some point. Today's computers work with binary streams.

Also note that sockets are low level components. In many cases when programs communicate, they can use higher level libraries that use socket internally.