怎么听这已经被另一个应用程序听了一个TCP端口 [英] How to listen to a TCP port which is already being listened by another app
问题描述
我有一个插件,它总是侦听的端口6002,和我有这将消息发送到相同的端口与接收同一个端口上从插件的答复的ASP.net应用程序,
发送工作正常,和插件发送相同的端口上的答复,但我不知道如何抓住这个答复,当我尝试收听使用的的TCPListener start方法抛出这个异常:每个套接字地址的一个用法(协议/网络地址/端口)通常是允许的,
I've a plugin which always listening to the port 6002, and i have an ASP.net application which sending messages to the same port and receiving the reply from the plugin on the same port, Sending is working fine, and the plugin sends a reply on the same port but i don't know how to catch this reply, when i try to listen to the same port using Tcplistener the start method throws this exception : Only one usage of each socket address (protocol/network address/port) is normally permitted,
有没有办法赶上收到的消息
谢谢
is there any way to catch the received message Thanks
推荐答案
我已经用这种方式解决了这个问题,等我知道这是老方法,但它的工作!
I've solved this problem using this way ,, I know it's old method but it's working !! :
'/*Variables Initialization*/
dim objSocket, strServicePort, strIpAddr, strResult, strMsgTo, strMsgResponse
strServicePort = "6002"
strIpAddr = "127.0.0.1"
'/* Create a TCP/IP socket. */
objSocket = Server.CreateObject("Intrafoundation.TCPClient.3")
objSocket.ClearLog()
'/* Establish socket connection. */
objSocket.Open (strIpAddr,strServicePort)
objSocket.Timeout=60.0
strMsgTo ="---- Message here ----"
'/* Send request message to plugin */
objSocket.SendRN(strMsgTo)
'/* receive XML Request Message from plugin */
strMsgResponse = objSocket.Recv()
strMsgResponse = Replace(strMsgResponse, vbLf, "")
objSocket.Close()
这篇关于怎么听这已经被另一个应用程序听了一个TCP端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!