Results 1 to 19 of 19

Thread: listening on a remote machine

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    Question 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

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: listening on a remote machine

    What exactly is PBX?

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    Re: listening on a remote machine

    Private business exchange.. pls look it up on google or webopedia ..i dnt have time for this

  6. #6
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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?

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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..

  8. #8
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: listening on a remote machine

    well
    Code:
    winsock1.Listen
    should be in Form_Load event.
    Then try connecting and see what happens.

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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!

  10. #10
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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.

  11. #11
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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?

  12. #12

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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

  13. #13
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

    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.

  14. #14

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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.

    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.

  15. #15
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

    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.

  16. #16
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  17. #17

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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!

  18. #18
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    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
    noister
    <advertising link removed by moderator>

  19. #19

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    9

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width