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

📄 server1.cpp

📁 windows 网络编程。pdf文档
💻 CPP
字号:
// Module Name: Server1.cpp
//
// Purpose:
//     Demonstrates how to write a mailslot server application
//
// Compile:
//     cl -o Server1 Server1.cpp
//
// Command Line Options:
//     None
//

#include <windows.h>
#include <stdio.h>

void main(void)
{
	HANDLE Mailslot;
	char buffer[256];
	DWORD NumberOfBytesRead;

	// Create the mailslot
	if ((Mailslot = CreateMailslot("\\\\.\\Mailslot\\Myslot", 0,
		MAILSLOT_WAIT_FOREVER, NULL)) == INVALID_HANDLE_VALUE)
	{
		printf("Failed to create a mailslot %d\n", GetLastError());
		return;
	}

	// Read data from the mailslot forever!
	while(ReadFile(Mailslot, buffer, 256, &NumberOfBytesRead,
		NULL) != 0)
	{
		buffer[NumberOfBytesRead] = 0;
		printf("%s\n", buffer);
	}
}

⌨️ 快捷键说明

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