⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 send_blocking.cpp

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 CPP
字号:
#include "sockets.h"// Function name	: SendBlocking// Description	    : // Return type		: int // Argument         : SOCKET sock// Argument         : char *buffer// Argument         : int length// Argument         : int flagsint SendBlocking(SOCKET sock, char *buffer, int length, int flags){	WSABUF buf;	int error;	DWORD num_sent;	buf.buf = buffer;	buf.len = length;	while (WSASend(sock, &buf, 1, &num_sent, flags, NULL, NULL) == SOCKET_ERROR)	{		error = WSAGetLastError();		if (error == WSAEWOULDBLOCK)		{			continue;		}		if (error == WSAENOBUFS)		{			// If there is no buffer space available then split the buffer in half and send each piece separately.			SendBlocking(sock, buf.buf, buf.len/2, flags);			SendBlocking(sock, buf.buf+(buf.len/2), buf.len - (buf.len/2), flags);			return length;		}		WSASetLastError(error);		return SOCKET_ERROR;	}	return length;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -