PDA

Click to See Complete Forum and Search --> : Port Listener


UrlGuy
May 23rd, 2005, 06:10 PM
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:


Private Sub Command1_Click()
Winsock1.GetData strData
Text1.Text = strData
Winsock2.GetData strData
Text2.Text = strData
MsgBox "Data retrieved", vbOKOnly, "Info"
End Sub

Private Sub Form_Load()
Winsock1.LocalPort = 4848
Winsock1.LocalPort = 25300
Winsock2.LocalPort = 4848
Winsock2.LocalPort = 25300
Winsock1.RemotePort = 4848
Winsock1.Bind 4848
Winsock2.RemotePort = 25300
Winsock2.Bind 25300
Winsock1.RemoteHost = "127.0.0.1"
Winsock2.RemoteHost = "127.0.0.1"
End Sub

Private Sub Winsock1_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData
Text1.Text = strData
End Sub

Private Sub Winsock2_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
Winsock2.GetData strData
Text2.Text = strData
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.

UrlGuy
May 23rd, 2005, 08:10 PM
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.

tek.Nami
May 24th, 2005, 03:38 PM
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

UrlGuy
May 25th, 2005, 09:33 AM
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?

tek.Nami
May 25th, 2005, 02:52 PM
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.

UrlGuy
May 26th, 2005, 09:00 PM
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 :[

asmdev
May 26th, 2005, 09:41 PM
Dim broadcastContent As String

Private Sub Command1_Click()
broadcastContent = Text1.Text
End Sub

Private Sub Form_Load()
Label1.Caption = "Simple UDP Server which broadcast the message you " & vbCrLf & "submit to 255.255.255.255."
Winsock1.Protocol = sckUDPProtocol
Winsock1.RemoteHost = "255.255.255.255"
Winsock1.RemotePort = 8090
Winsock1.Bind 8080

Winsock2.Protocol = sckUDPProtocol
Winsock2.RemoteHost = "255.255.255.255"
Winsock2.RemotePort = 8080
Winsock2.Bind 8090
End Sub

Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
Winsock2.Close
End Sub

Private Sub Timer1_Timer()
Static broadcastCount As Double
broadcastCount = broadcastCount + 1

If broadcastContent = "SHUTDOWN" Then
Winsock1.SendData "SHUTDOWN"
Else
Winsock1.SendData "TESTING " & CStr(broadcastCount) & vbCrLf & broadcastContent
End If
End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim tmp As String
Winsock2.GetData tmp
If tmp = "SHUTDOWN" Then
Unload Me
Else
Text2.Text = tmp
End If

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.

http://img72.echo.cx/img72/1231/image17lb.png

UrlGuy
May 26th, 2005, 09:52 PM
Thanks for your reply, but not excactly what I were looking for.. :]

ocw
Jun 16th, 2005, 06:35 AM
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

blainenewman
Sep 3rd, 2007, 02:31 PM
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

Jason Ra
Jul 30th, 2009, 12:56 PM
asmdev -

Does your emample work in VB 2008? - Thanks.