compat.cpp.svn-base

来自「这是一个很好的参考代码」· SVN-BASE 代码 · 共 33 行

SVN-BASE
33
字号
#include <string>#include <vector>#include "compat.h"bool Connect(SOCKET sockfd, const SOCKADDR_IN& addr) {  return bool(connect(sockfd, (sockaddr*)&addr, addr.get_size()) == 0);}bool Socket(SOCKET& s, int domain, int type, int protocol) {  s = socket(AF_INET, type, protocol);  return bool(s != -1);}bool Send(int &CharsSent, SOCKET s, const char *msg, size_t len, int flags) {  CharsSent = send(s, msg, len, flags);  return bool((CharsSent != -1));}bool Recv(int &CharsRecv, SOCKET s, char *buf, size_t len, int flags) {  CharsRecv = recv(s, buf, len, flags);  return bool((CharsRecv != -1));}// just wrap the call to shutdown the connection on a socket// this way I don't have to call it this way everywhere.void Closesocket(const SOCKET& s) {  close(s);}void initNetworking() {  return;}

⌨️ 快捷键说明

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