Results 1 to 11 of 11

Thread: Port Listener

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Location
    Norway
    Posts
    71

    Port Listener

    Hi,

    I have made this small program which is supposed to log incoming traffic on UDP port 4848 and 25300.

    I have made two texboxes to log each ports traffic, and I have added 2 Winsock controls, both for UDP. I also have a button to retrieve the logged data.. althoug the best would be if it refreshed itself as it retrieved the data..

    Heres my code:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Winsock1.GetData strData
    3.     Text1.Text = strData
    4.     Winsock2.GetData strData
    5.     Text2.Text = strData
    6.     MsgBox "Data retrieved", vbOKOnly, "Info"
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. Winsock1.LocalPort = 4848
    11. Winsock1.LocalPort = 25300
    12. Winsock2.LocalPort = 4848
    13. Winsock2.LocalPort = 25300
    14. Winsock1.RemotePort = 4848
    15. Winsock1.Bind 4848
    16. Winsock2.RemotePort = 25300
    17. Winsock2.Bind 25300
    18. Winsock1.RemoteHost = "127.0.0.1"
    19. Winsock2.RemoteHost = "127.0.0.1"
    20. End Sub
    21.  
    22. Private Sub Winsock1_DataArrival _
    23. (ByVal bytesTotal As Long)
    24.     Dim strData As String
    25.     Winsock1.GetData strData
    26.     Text1.Text = strData
    27. End Sub
    28.  
    29. Private Sub Winsock2_DataArrival _
    30. (ByVal bytesTotal As Long)
    31.     Dim strData As String
    32.     Winsock2.GetData strData
    33.     Text2.Text = strData
    34. End Sub


    The problem is this isnt working at all.. when I start it my firewall tells me something is trying to connect thru/to? it tho.. although it doesnt give me any output at all... all help here are greatly apprecciated!!!

    Thanks.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Location
    Norway
    Posts
    71

    Re: Port Listener

    Okay I'll try explain a little more simple;

    What I want to do is.. I want to have a textbox in my program which listens to incoming traffic on UDP port 25300 and output it in the textbox.

  3. #3
    New Member
    Join Date
    May 2005
    Posts
    9

    Re: Port Listener

    shouldnt you have it display the info you get in a label, and, disable all firewalls, like a router, windows firewall, and the mcafee and norton stuff, or any others

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Location
    Norway
    Posts
    71

    Re: Port Listener

    Yea I can display it in a label if that is needed.
    I can turn off firewall, nat etc if thats needed too. :]

    Any idea how I can do this?

  5. #5
    New Member
    Join Date
    May 2005
    Posts
    9

    Re: Port Listener

    supposing you have broadband internet, open up a web browswer and type in the IP address of your router, probly "192.168.2.1" or "192.168.1.1" without the quotes. Then disable the router firewall. The others i talked about are software firewalls and shouldnt be too hard to turn off, this is going off of that your coding is correct. If this doenst work then your code probly needs tweaking, and dont forget to enable your firewalls again.

    And we have been taught to display messages in labels not text boxes, but thats just us.

    Sorry i cant help much, if any, with coding, im more of a pc hardware/networking guy.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Location
    Norway
    Posts
    71

    Re: Port Listener

    But um.. I dont run a firewall so it shouldnt be a problem as all traffic are allowed..

    All I want is.. a program which logs all incoming UDP traffic and displays it as HEX strings in a textbox/label or w.e possible


    This seems to be a very hard task :[

  7. #7
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: Port Listener

    VB Code:
    1. Dim broadcastContent As String
    2.  
    3. Private Sub Command1_Click()
    4.     broadcastContent = Text1.Text
    5. End Sub
    6.  
    7. Private Sub Form_Load()
    8.     Label1.Caption = "Simple UDP Server which broadcast the message you " & vbCrLf & "submit to 255.255.255.255."
    9.     Winsock1.Protocol = sckUDPProtocol
    10.     Winsock1.RemoteHost = "255.255.255.255"
    11.     Winsock1.RemotePort = 8090
    12.     Winsock1.Bind 8080
    13.    
    14.     Winsock2.Protocol = sckUDPProtocol
    15.     Winsock2.RemoteHost = "255.255.255.255"
    16.     Winsock2.RemotePort = 8080
    17.     Winsock2.Bind 8090
    18. End Sub
    19.  
    20. Private Sub Form_Unload(Cancel As Integer)
    21.     Winsock1.Close
    22.     Winsock2.Close
    23. End Sub
    24.  
    25. Private Sub Timer1_Timer()
    26.     Static broadcastCount As Double
    27.     broadcastCount = broadcastCount + 1
    28.    
    29.     If broadcastContent = "SHUTDOWN" Then
    30.         Winsock1.SendData "SHUTDOWN"
    31.     Else
    32.         Winsock1.SendData "TESTING " & CStr(broadcastCount) & vbCrLf & broadcastContent
    33.     End If
    34. End Sub
    35.  
    36. Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    37.     Dim tmp As String
    38.     Winsock2.GetData tmp
    39.     If tmp = "SHUTDOWN" Then
    40.         Unload Me
    41.     Else
    42.         Text2.Text = tmp
    43.     End If
    44.    
    45. End Sub

    ok, this is wat i made for fun, u got a UDP broadcaster and the receiver have fun with it :0

    try typing "SHUTDOWN" to exit the program.

    Last edited by asmdev; May 26th, 2005 at 09:45 PM.
    if u felt my post make u happy ,
    then u could make me happy too by rating my post

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Location
    Norway
    Posts
    71

    Re: Port Listener

    Thanks for your reply, but not excactly what I were looking for.. :]

  9. #9
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    277

    Re: Port Listener

    hi all,

    this seem very interesting!.. i would like to know if TCP/IP could do the same thing too?

    e.g To:
    1. broadcast/multicast file or image to the rest of the stations in the network?


    i have tried to send images to the other party in the network using TCP/IP, its work. But, when i broadcast the IP to ( ####.####.####.255). the sending fails to do so. why does this happen? is it due to the firewall? or the wrong port delegated?


    ???
    ocw

  10. #10
    New Member
    Join Date
    Sep 2007
    Posts
    4

    Re: Port Listener

    can someone explain to me when to use the bind() method?

    I think its when you want to select among multiple NIC's?

    Or when you want to use a range of ports as apposed to using just one port?

    Thanks

  11. #11
    Member
    Join Date
    Jul 2009
    Posts
    37

    Re: Port Listener

    asmdev -

    Does your emample work in VB 2008? - Thanks.

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