我正在使用AxInterop.MSWinsockLib.dll和Interop.MSWinsockLib.dll和MSWINSCK.OCX来创建与打印机的套接字连接。以下代码是我使用的,但无论我是否在尝试连接后将代码放在while循环或Thread.Sleep()中,连接状态仍然保持在6,即“正在连接”。请尽快帮助。
Try
Dim sock As AxMSWinsockLib.AxWinsock
sock = New AxMSWinsockLib.AxWinsock
CType(sock, System.ComponentModel.ISupportInitialize).BeginInit()
Me.Controls.Add(sock)
CType(sock, System.ComponentModel.ISupportInitialize).EndInit()
sock.RemoteHost = "10.194.1.132"
sock.RemotePort = 3001
sock.Connect()
MessageBox.Show(sock.CtlState.ToString())
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try