Unix Programming - read() vs. recv() for sockets operations

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2005 > read() vs. recv() for sockets operations





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author read() vs. recv() for sockets operations
Roman Mashak

2005-11-18, 2:49 am

Hello, All!

What are the benefits/drawbacks of using read() on socket operations, except
it's a general way for dealing with file descriptors? What about portability
etc.?

With best regards, Roman Mashak. E-mail: mrv@tusur.ru


Måns Rullgård

2005-11-18, 2:49 am

"Roman Mashak" <mrv@tusur.ru> writes:

> Hello, All!
>
> What are the benefits/drawbacks of using read() on socket operations, except
> it's a general way for dealing with file descriptors? What about portability
> etc.?


recv() takes an extra flags parameter. That's the only difference.

--
Måns Rullgård
mru@inprovide.com
Roman Mashak

2005-11-18, 7:50 am

Hello, Måns!
You wrote on Fri, 18 Nov 2005 08:44:44 +0000:

??>> What are the benefits/drawbacks of using read() on socket operations,
??>> except it's a general way for dealing with file descriptors? What
??>> about portability etc.?

MR> recv() takes an extra flags parameter. That's the only difference.
I assume, both functions are equally portable?

With best regards, Roman Mashak. E-mail: mrv@tusur.ru


Valentin Nechayev

2005-11-18, 7:50 am

Fri, Nov 18, 2005 at 20:09:43, mrv (Roman Mashak) wrote about "read() vs. recv() for sockets operations":

RM> ??>> What are the benefits/drawbacks of using read() on socket operations,
RM> ??>> except it's a general way for dealing with file descriptors? What
RM> ??>> about portability etc.?
MR>> recv() takes an extra flags parameter. That's the only difference.
RM> I assume, both functions are equally portable?

For all Unix(-like) systems, yes. For Windows, no.


-netch-
Michel Bardiaux

2005-11-22, 7:50 am

Roman Mashak wrote:
> Hello, Måns!
> You wrote on Fri, 18 Nov 2005 08:44:44 +0000:
>
> ??>> What are the benefits/drawbacks of using read() on socket operations,
> ??>> except it's a general way for dealing with file descriptors? What
> ??>> about portability etc.?
>
> MR> recv() takes an extra flags parameter. That's the only difference.
> I assume, both functions are equally portable?
>
> With best regards, Roman Mashak. E-mail: mrv@tusur.ru
>
>

On Unix, read or recv will do exactly the same (apart from the flags
thing). On Windows, read() on a socket is not allowed. So, for
portability it is better to use recv for all sockets.


--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux@mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com