windows - When reading a socket in python, is there any difference between os.read and socket.recv? -


Suppose i have a socket, what is the difference between these two lines of code?

Line 1:

  os.read (some_socket.fileno (), 1024)  

Line 2:

  some_socket.recv (1024)  

... More than the fact that the first one does not work on Windows. In other words, can I change the option of the second line for the first time? I have a codebase that has not actually been tested with Windows, and it is causing trouble.

The line 1 socket uses the underlined file descriptor to read, so it depends on the platform. Use Line 2 because it is a portable, multi-platform way to fulfill the same thing.

Mandatory: If you're doing something serious, it would be better to deal with lower level sockets. It is difficult to recover, it may seem that things are working but there are many details those details have already been resolved in many networking frameworks and there is no reason to change the wheel again. I suggest, it's great.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -