类似于局域网游戏服务器查找,象魔兽,当一台机器创建一个游戏后(姑且称为服务器),其他的机器(客户端)就可以查看到,我想应该是客户端广播一个查询报文,服务器在收到此报文后给出回告。我现在不是很清楚到底如何控制这个查询报文的接收群体,是否 以*.*.*.255 方式广播就表示只有IP前三段相同的机器才能收到,而以 255.255.255.255方式广播就可以让更多的机器收到(坦白说,我还没有试过255.255.255.255方式能否广播成功),或者怎样才能只让出现在网上邻居里整个网络(不同工作组,我想它们的IP应该是可以四段都不同)的机器收到。
请高手指点。
请高手指点。
解决方案 »
- 50分!程序一最小化就出现断言错误!
- 系统A如何获取系统B的拥有输入焦点的窗口的句柄
- 简单问题
- ocx怎样打包为cab文件?高手请闲庭信步。
- RowLength = ((bmch.bcWidth * bmch.bcBitCount + 31) & ~31) >> 3 是什么意思啊?新手上路,多多指导……谢谢
- winpcap可以抓到本机往外发出的包吗?
- 查询子句有问题?
- 如何编程使Static 控件中的文本不能换行!
- 重开一帖:关于在两个进程间发送自定义消息的问题。
- 请问压缩字符串的时候,应该怎样把字符串的原长写入压缩后的字符串?
- 局域网中发送广播消息
- 如果我用的usb芯片根本不出名,例如小强牌的,但做成了一个mass storage的系统,那windows端需要装驱动么?
HDC hdc,
LPNETRESOURCE lpnr)
{
DWORD dwResult, dwResultEnum;
HANDLE hEnum;
DWORD cbBuffer = 16384; // 16K is a good size
DWORD cEntries = -1; // enumerate all possible entries
LPNETRESOURCE lpnrLocal; // pointer to enumerated structures
DWORD i;
//
// Call the WNetOpenEnum function to begin the enumeration.
//
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, // all network resources
RESOURCETYPE_ANY, // all resources
0, // enumerate all resources
lpnr, // NULL first time the function is called
&hEnum); // handle to the resource if (dwResult != NO_ERROR)
{
//
// Process errors with an application-defined error handler.
//
NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetOpenEnum");
return FALSE;
}
//
// Call the GlobalAlloc function to allocate resources.
//
lpnrLocal = (LPNETRESOURCE) GlobalAlloc(GPTR, cbBuffer);
do
{
//
// Initialize the buffer.
//
ZeroMemory(lpnrLocal, cbBuffer);
//
// Call the WNetEnumResource function to continue
// the enumeration.
//
dwResultEnum = WNetEnumResource(hEnum, // resource handle
&cEntries, // defined locally as -1
lpnrLocal, // LPNETRESOURCE
&cbBuffer); // buffer size
//
// If the call succeeds, loop through the structures.
//
if (dwResultEnum == NO_ERROR)
{
for(i = 0; i < cEntries; i++)
{
// Call an application-defined function to
// display the contents of the NETRESOURCE structures.
//
DisplayStruct(hdc, &lpnrLocal[i]); // If the NETRESOURCE structure represents a container resource,
// call the EnumerateFunc function recursively. if(RESOURCEUSAGE_CONTAINER == (lpnrLocal[i].dwUsage
& RESOURCEUSAGE_CONTAINER))
if(!EnumerateFunc(hwnd, hdc, &lpnrLocal[i]))
TextOut(hdc, 10, 10, "EnumerateFunc returned FALSE.", 29);
}
}
// Process errors.
//
else if (dwResultEnum != ERROR_NO_MORE_ITEMS)
{
NetErrorHandler(hwnd, dwResultEnum, (LPSTR)"WNetEnumResource");
break;
}
}
//
// End do.
//
while(dwResultEnum != ERROR_NO_MORE_ITEMS);
//
// Call the GlobalFree function to free the memory.
//
GlobalFree((HGLOBAL)lpnrLocal);
//
// Call WNetCloseEnum to end the enumeration.
//
dwResult = WNetCloseEnum(hEnum);
if(dwResult != NO_ERROR)
{
//
// Process errors.
//
NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetCloseEnum");
return FALSE;
} return TRUE;
}
1.局域网游戏只能在本网段内玩吧?
2.“不同工作组,我想它们的IP应该是可以四段都不同”这句话可能有点问题。一个网段内可以有很多不同的工作组。但是IP四段都不同的机器不会在同一个网段,你也不能和他们玩游戏。