|
-
May 23rd, 2005, 06:10 PM
#1
Thread Starter
Lively Member
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:
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.
-
May 23rd, 2005, 08:10 PM
#2
Thread Starter
Lively Member
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.
-
May 24th, 2005, 03:38 PM
#3
New Member
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
-
May 25th, 2005, 09:33 AM
#4
Thread Starter
Lively Member
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?
-
May 25th, 2005, 02:52 PM
#5
New Member
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.
-
May 26th, 2005, 09:00 PM
#6
Thread Starter
Lively Member
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 :[
-
May 26th, 2005, 09:41 PM
#7
Addicted Member
Re: Port Listener
VB Code:
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.
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
-
May 26th, 2005, 09:52 PM
#8
Thread Starter
Lively Member
Re: Port Listener
Thanks for your reply, but not excactly what I were looking for.. :]
-
Jun 16th, 2005, 06:35 AM
#9
Hyperactive Member
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
-
Sep 3rd, 2007, 02:31 PM
#10
New Member
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
-
Jul 30th, 2009, 12:56 PM
#11
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|