我有两个基于套接字的现有客户机/服务器win32项目,其中客户机向服务器发送字符串请求,并使用套接字函数(即send(),recv())以字符串形式接收结果
服务器代码的一部分
struct client_ctx
{
int socket;
CHAR buf_recv[MAX_SEND_BUF_SIZE]; // receive buffer
CHAR buf_send[MAX_SEND_BUF_SIZE]; // send buffer
unsigned int sz_recv; // size of recv buffer
unsigned int sz_send_total; // size of send buffer
unsigned int sz_send; // size of data send
// OVERLAPPED structures for notifications of completition
OVERLAPPED overlap_recv;
OVERLAPPED overlap_send;
OVERLAPPED overlap_cancel;
DWORD flags_recv; // Flags for WSARecv
};
struct client_ctx g_ctxs[1 + MAX_CLIENTS];
void schedule_write(DWORD idx)
{
WSABUF buf; buf.buf = g_ctxs[idx].buf_send + g_ctxs[idx].sz_send;
buf.len = g_ctxs[idx].sz_send_total - g_ctxs[idx].sz_send;
memset(&g_ctxs[idx].overlap_send, 0, sizeof(OVERLAPPED));
WSASend(g_ctxs[idx].socket, &buf, 1, NULL, 0, &g_ctxs[idx].overlap_send, NULL);
}
并且使用上述功能,我将请求的数据发送到客户端
我从服务器发送的数据
static class SystemInfo{
public :
static std::string GetOSVersion();
static std::string GetCurrentTimeStr();
static std::string GetTimeSinceStartStr();
static std::string GetFreeMemoryStr();
static std::string GetFreeSpaceStr();
static std::string CheckAccess();
static void CheckFileAccessRights(wchar_t *path);
static std::string CheckKeyFileDirectoryAccessRights(wchar_t *char_path, wchar_t *char_buf);
static BOOL GetCurrentProcessSID();
static std::string UserNameFromSid(PSID userSid);
static BOOL FileOrDirectoryExists(LPCTSTR szPath);
};
问题是:是否有任何指南说明如何使用Midl编译器将SystemInfo类中的方法表示为可以远程调用的过程?我找不到如何将现有功能与远程过程调用连接(在我的情况下是从客户端使用它们)
的任何手册。