-
udp
I have udp send program and udp receiver program developed using vb.net 2003.Receiver program(pc) has 2 network card one for LAN and other for internet(WAN).This 2 program working in LAN.But when it goes to the internet(WAN) my receiver program seem did not receive any msg from sender.For your information on internet mode i can access internet.Anyone know how to solve my problem?
-
Re: udp
Welcome to the VBForum.
I'd suggest you change your Nickname, because it will be easily detected by searching-"machines" and you will get endless spams!
How do you set the IP for the UDP-receiver? Do you set it fixed to the LAN-Card, or is it set by the system (there could be the error).
-
Re: udp
thank u opus for your reply.
udp receiver on lan i used fixed ip but on wan i used dynamic ip.several people said i should use nat or port forwarding or rendezvous point.But i can't see clearly in my mind how to do such that.
by the way how to change my my username?sorry for silly question
-
Re: udp
@Changing UserName: In your case (New Member), I'd create a new one (you have only two posts so far) ;-)
@UDP Reciever: I understand your Network-card for the LAN is using a fixed IP, however the question was how you set the used IP for the UDP-connection your application is listening on?
-
Re: udp
here udp receive code :
'declaration
Public receivingUdpClient As New UdpClient(11000)
Dim aa As System.Net.IPAddress
Dim SocketNO As Integer
'form load
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
aa = IPAddress.Parse(ip.Text)'key in ip
SocketNO = Val(portno.Text)'port to use
RemoteIpEndPoint = New System.Net.IPEndPoint(aa, SocketNO)
Me.Show()
End Sub
'start to receive
Public Sub ReceiveMessages()
On Error Resume Next
'Try
receivingUdpClient.Connect(RemoteIpEndPoint)
receiveBytes = receivingUdpClient.Receive(RemoteIpEndPoint)
'txtIP.Text = RemoteIpEndPoint.Address.ToString
tmp = Encoding.ASCII.Unicode.GetChars(receiveBytes)
test.Text = tmp
End Sub
'close connection
receivingUdpClient.Close()
Udp sender code i used exactly from code project http://www.codeproject.com/vb/net/UDP_Send_Receive.asp i used only udp send not udp receive.
any problem my code?please help me
Thanks
-
Re: udp
That code doesn't look like the code needed for a UDP-client to get data. Using UDP the clinet isn not "connecting", since the clinet is only listening. Look at the codeproject exmaple you used, the recieving part is also shown.
You need to use a backgroundworker thread (as something similar) in order to keep your main thread alive, while listening for incoming messages.
Looking at this code, I don't see how it could have worked. Did I misunderstand your post #1, I understood it worked when the receiver PC doesn't use the other network card to work in the internet?
-
Re: udp
let me give u all the scenarios of my project.
1. udp send and receive over lan
udp send will send udp packet to udp receive on LAN environment with fixed ip.This scenarios I've tested already and working nicely.
2.udp send and receice over wan
Second is same program same code it should work like 1st scenario but in WAN environment.I mean here udp send is from LAN send udp packet to other pc which in WAN.I put that ip destination and also the port.what i see is udp send is working but on receive side in wan cannot receive any packet from the source.Hope u all understand.
based on your previous posted 2 question
1.You re correct I'm not using receivingUdpClient.Connect because I'm only listening.So what are the code for a UDP-client to get data?
2.What is backgroundworker thread?
-
Re: udp
If it isn'T running on WAN ,try a search on port-forwarding.
Personally I've never worked on WAN, so no help on this one.
My questions
1.) forget it, since it's working on LAN:
2.)Your code needs to "Wait" for something being recieved, since you don'T want to halt to code just for that, you need to use a other thread. This one is waiting for something being recieved and then hands it over to the main thread. On we way to do that is a Backgroundworker thread.
-
Re: udp
thanks opus you help me a lot.