解析:教你轻松掌握命名管道客户端连接
下列过程描述当使用命名管道作为 IPC 机制时测试网络连接的方法。
测试命名管道连接
在客户端工作站中的操作系统命令提示符处键入:
net view //servername |
当使用 net view 时,servername 是想要连接的服务器的名称。
例如,若要检查命名管道客户端和名为 //SEATTLE1 的服务器之间的连接,请在客户端键入以下内容:
net view //SEATTLE1 |
如果连接已打开,则输出与以下类似:
共享资源位于 //SEATTLE1SQL Server共享名称 类型 用途备注----------------------------PUBLIC 磁盘 公用文件 |
命令成功完成。
验证与服务器的命名管道的连接
从命令提示符键入:
net use//servername/IPC$ |
当使用 net use 时,servername 是想要连接的服务器。
例如:
net use //SEATTLE1/IPC$ |
命令成功完成
如果客户端工作站和服务器之间的连接打开,但仍无法连接到 Microsoft® SQL Server™ 2000,请使用 makepipe 和 readpipe 实用工具测试网络和本地命名管道。这些实用工具包括在 SQL Server 内以帮助测试网络命名管道的完整性。
makepipe 和 readpipe 实用工具在客户端和服务器组件安装过程中安装。这些实用工具对于它们所运行于的不同操作系统有不同的版本:makepipe 运行于 Microsoft Windows NT®;readpipe 运行于 Windows NT、Microsoft Windows® 和 MS-DOS®。务必为所测试的操作系统使用正确的版本。(运行于 Windows 的版本名为 readpipe。如果安装了 SQL Server 工具,则 readpipe 位于 /Msqql/Binn 目录;没有为它创建图标。)
测试网络命名管道服务的完整性
1.在服务器的操作系统命令提示符处键入:
makepipe |
makepipe 实用工具返回以下信息:
Making PIPE:/pipe/abcread to write delay (seconds):0Waiting for Client to Connect... |
SQL Server 正在等待客户端连接。
2.在客户端工作站的操作系统命令提示符处键入:
readpipe /Sserver_name /Dstring |
当使用 readpipe 时,server_name 是 SQL Server 的网络服务器名称(makepipe 在该服务器上启动),而 string 是测试字符串。如果字符串包含空格,则必须括在双引号内。/S 与服务器名称之间无空格,/D 与字符串之间无空格。
例如,若要连接到名为 myserver 的 SQL Server 安装,请键入下列内容之一:
readpipe /Smyserver /Dhelloreadpipe /Smyserver /D"hello there"readpipe /Smyserver /D'hello there' |
前两个 readpipe 语句中指定的字符串处理方法相同。
如果网络命名管道连接可以建立,则客户端工作站分别对前面的每个命令返回以下信息:
SvrName://myserverPIPE ://myserver/pipe/abcDATA :hello Data Sent: 1 : helloData Read: 1 : helloSvrName://myserverPIPE ://myserver/pipe/abcDATA :hello thereData Sent: 1 :hello thereData Read: 1 :hello thereSvrName://myserverPIPE ://myserver/pipe/abcDATA :hello Data Sent: 1 : 'helloData Read: 1 : 'hello |
如果网络命名管道连接可以建立,则 makepipe 实用工具返回与以下类似的信息:
Waiting for Client to Connect...Waiting for client to send... 1Data Read:helloWaiting for client to send... 2Pipe closedWaiting for Client to Connect...Waiting for client to send... 1Data Read:hello thereWaiting for client to send... 2Pipe closedWaiting for Client to Connect...Waiting for client to send... 1Data Read:'helloWaiting for client to send... 2Pipe closedWaiting for Client to Connect... |
在此时,SQL Server 等待客户端进行连接。readpipe 实用工具可以从其它工作站运行。
3.当测试完成时,转到 makepipe 实用工具所运行于的服务器,按 CTRL+BREAK 或 CTRL+C。
如果结果与第 2 步中的不同,则网络命名管道服务不可用。如果使用命名管道作为 IPC 机制,则客户端无法连接到 SQL Server,直到有可用的命名管道。这些实用工具尝试打开和使用某个命名管道;它们不强迫命名管道连接。 (责任编辑:卢兆林)