Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Низкоуровневое программирование > Win Api
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 03.04.2010, 17:11   #1
Dimarik
Форумчанин
 
Аватар для Dimarik
 
Регистрация: 18.04.2009
Сообщений: 688
По умолчанию recv Function

вот что MSDN дало:
The recv function receives data from a connected or bound socket.


int recv(
__in SOCKET s,
__out char* buf,
__in int len,
__in int flags
);

Parameters
s
The descriptor that identifies a connected socket.

buf
The buffer for incoming data.

len
The length, in bytes, of the buf parameter.

flags
A pointer to flags that influences the behavior of this function. See remarks below.

Return Value
If no error occurs, recv returns the number of bytes received. If the connection has been gracefully closed, the return value is zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

The flags parameter can be used to influence the behavior of the function invocation beyond the options specified for the associated socket. The semantics of this function are determined by the socket options and the flags parameter. The latter is constructed by using the bitwise OR operator with any of the following values.

Value Meaning
MSG_PEEK Peeks at the incoming data. The data is copied into the buffer, but is not removed from the input queue. The function subsequently returns the amount of data that can be read in a single call to the recv (or recvfrom) function, which may not be the same as the total amount of data queued on the socket. The amount of data that can actually be read in a single call to the recv (or recvfrom) function is limited to the data size written in the send or sendto function call.
MSG_OOB Processes Out Of Band (OOB) data.
MSG_WAITALL The receive request will complete only when one of the following events occurs:

The buffer supplied by the caller is completely full.
The connection has been closed.
The request has been canceled.
Note that if the underlying transport does not support MSG_WAITALL, or if the socket is in a non-blocking mode, then this call will fail with WSAEOPNOTSUPP. Also, if MSG_WAITALL is specified along with MSG_OOB, MSG_PEEK, or MSG_PARTIAL, then this call will fail with WSAEOPNOTSUPP. This flag is not supported on datagram sockets or message-oriented CO sockets.





ВОПРОС.
1. где-то встретил что на месте flags был написан 0, вместо этих 3ёх констант, что бы это могло значить?
2. MSG_OOB Processes Out Of Band (OOB) data.
как это понять???? что такое OOB?
Dimarik вне форума Ответить с цитированием
Старый 03.04.2010, 17:53   #2
Пепел Феникса
Старожил
 
Аватар для Пепел Феникса
 
Регистрация: 28.01.2009
Сообщений: 21,000
По умолчанию

1)0 это значит что ни один из флагов не применяется.
2)не знаю если честно..
Хорошо поставленный вопрос это уже половина ответа. | Каков вопрос, таков ответ.
Программа делает то что написал программист, а не то что он хотел.
Функции/утилиты ждут в параметрах то что им надо, а не то что вы хотите.
Пепел Феникса вне форума Ответить с цитированием
Старый 04.04.2010, 11:53   #3
profi
Участник клуба Подтвердите свой е-майл
 
Регистрация: 19.11.2007
Сообщений: 1,022
По умолчанию

Цитата:
Флаг MSG_OOB предназначен для передачи и приема срочных (Out Of Band) данных. Срочные данные не имеют преимущества перед другими при пересылке по сети, а всего лишь позволяют оторвать клиента от нормальной обработки потока обычных данных и сообщить ему "срочную" информацию. Если данные передавались функцией send с установленным флагом MSG_OOB, для их чтения флаг MSG_OOB функции recv так же должен быть установлен.
К.Касперски "Самоучитель игры на WINSOCK"
profi вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
MPI: send и recv cheparamba Общие вопросы C/C++ 0 09.03.2010 05:48
Функция recv (Winsock) YYYYY Работа с сетью в Delphi 0 18.02.2010 02:16
Зацикливается recv. asdo Общие вопросы C/C++ 4 23.01.2010 23:38
recv() Артэс C/C++ Сетевое программирование 7 15.01.2010 14:51
WinSock (send, recv) AidarBik Работа с сетью в Delphi 1 27.07.2008 15:22