listening on a remote machine
i currently hav a program that reads a localPort to capture call data sent from a PBX. this is wht it looks like..
Code:
form_load
..
winsock1.protocol=sckTCPprotocol
Winsock1.LocalPort = 1200
Winsock1.Listen
..
end sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
DoEvents
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sitem As String
Winsock1.GetData sitem
.. code to handle data
End Sub
now things have changed and call data is sent to a remote device that is connected to the PBX. hence i need to connect to a specific port on the remote device to read the data. i can see the data thru hyperterminal if i set the remote host and the port. but how can i modify the above program so that i can read the data from the remote machine.
just to make this clear.. this raw TCP..and does not involve issuing commands like telnet..
thanks
Re: listening on a remote machine
Maybe have a separate winsock control for what you need?
Well basically you will need to connect to the device and use the GetData method to retrieve all the data you want.
Re: listening on a remote machine
i dont see a need for a separate winsock control.. the current one im not using anymore.. since the data is not sent to the local machine..
have u tried connecting to a remote machine and listening? it does not work for me.. this is what i tried modified my form load
Code:
winsock1.remotehost =Ipaddress
winsock1.remoteport=port
winsock1.listen
Re: listening on a remote machine
Re: listening on a remote machine
Private business exchange.. pls look it up on google or webopedia ..i dnt have time for this
Re: listening on a remote machine
Me either i should be in bed as it is 11:00 PM and i have a test to tomorrow so please be thankful.
Now do you get any specific errors with what you are attempting at the moment?
Re: listening on a remote machine
nope.. i dnt get any errors.. the winsock events for connection request and data arrival does not get fired.. meaning its not listening to the port.
i dont get any errors in the winsock error event either..
Re: listening on a remote machine
well should be in Form_Load event.
Then try connecting and see what happens.
Re: listening on a remote machine
Quote:
Originally Posted by azwaan
i dont see a need for a separate winsock control.. the current one im not using anymore.. since the data is not sent to the local machine..
have u tried connecting to a remote machine and listening? it does not work for me.. this is what i tried modified my form load
Code:
winsock1.remotehost =Ipaddress
winsock1.remoteport=port
winsock1.listen
its already there!
Re: listening on a remote machine
that is in the Form_Load Event!?
Well the order is wrong. It is trying to connect before even listening.
Re: listening on a remote machine
Also just noticed where is your code telling it to connect? I assume that would be part of a Button Click event or something similar?
Re: listening on a remote machine
i just need to listen on the remote port of the device.. for the data that is being sent by the PBX to the device.. pls port ur sample code.. so that i can understand wht ur saying..
also look at my first post with my working code for listening on the local machine.. i just need it modified to enable listening to a remote port instead
Re: listening on a remote machine
Quote:
Originally Posted by azwaan
i just need to listen on the remote port of the device.. for the data that is being sent by the PBX to the device.. pls port ur sample code.. so that i can understand wht ur saying..
also look at my first post with my working code for listening on the local machine.. i just need it modified to enable listening to a remote port instead
I think you need to be a little more polite to people who are taking the time to help you out. :mad:
You can't do what you're asking. The Listen method of the Winsock control is LOCAL. Not remote. You would have to have the remote computer forward the data to your computer.
Re: listening on a remote machine
Quote:
Originally Posted by DigiRev
I think you need to be a little more polite to people who are taking the time to help you out. :mad:
You can't do what you're asking. The Listen method of the Winsock control is LOCAL. Not remote. You would have to have the remote computer forward the data to your computer.
well its not really helpful.. when i have to repeat things.. and have to describe things which are totally irrelevant to the question. i suggest all of us (including myself) read the question fully and understand it , without blindly replying..
well if i cant do it with the Listen method , there has to be someway of doing it with winsock. and btw its a remote device (machine) not a computer as i hav said. and NO it cannot forward the data to the local machine. if this was possible my existing code would have done it.
if i can view the data thru hyperterminal by specifiying the host and the port, i guess there shud be a way of doing the same thru winsock.
Re: listening on a remote machine
Quote:
Originally Posted by azwaan
well its not really helpful.. when i have to repeat things.. and have to describe things which are totally irrelevant to the question. i suggest all of us (including myself) read the question fully and understand it , without blindly replying..
Your attitude makes it hard to want to help, to be honest. No one here is getting paid to *try* and help people. They're doing it in their own free time. So I think you should be at least somewhat thankful that someone even responds to your thread to begin with.
Quote:
if i can view the data thru hyperterminal by specifiying the host and the port, i guess there shud be a way of doing the same thru winsock.
You can make TCP connections with winsock by specifying a remote host and port and calling the connect method.
You haven't given a lot of details about what kind of machine it is and how you are trying to do this.
You just said you want to 'listen' on a remote computer. And listen is a local thing. If you want to see data being sent/received on a remote computer or machine, then that machine has to have a function that can send the data to you. Maybe if you establish a connection with it, then it will. Or send a request/command for the data.
If the machine was not designed for that and you can't run your own software on it or reprogram it in anyway then you can't do it.
Re: listening on a remote machine
The data is being sent TO the port on the remote device, not being sent BY it. You can't "listen to" the data being sent to another computer without packet sniffing.
Re: listening on a remote machine
i got it working!!
actually it seems tht i can see the data in hyperterminal cos the device sends the data when i connect to the device. i just needed to rewrite my code as a client instead of listening.
i initially thought data can be received only if ur listening, but instead in this case i connect and wait for the device to send me the data.
thanks for all ur input!
Re: listening on a remote machine
hi azwaan,
can u post your code or PM it to me... that's what i also looking for.
tnx... noielen
Re: listening on a remote machine
Code:
privtae sub Form_load()
...
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemoteHost = RemoteHost ' // IP Address
Winsock1.RemotePort = 2001
Winsock1.Connect
..
end sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData '// strData contains data sent by device
'// do some processing
...
...
end sub
hope this helps!