Last post Apr 16, 2013 01:29 AM by markgroner
Apr 21, 2006 06:15 PM|SteveNutt|LINK
I have a hosted web application / web service that needs to receive UDP packets. Thinking that this was not possible, I went ahead and wrote a UDP server in Windows Forms based on some code I found on another forum. I recently revisited the forum and found
that another developer had decided to put the code to initialize the UDPClient into the init() of the global.asax of a web application and apparantly it worked......
<code>Public Overrides Sub Init()
SocketNO = 80
receivingUdpClient = New System.Net.Sockets.UdpClient(SocketNO)
ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
The ReceiveMessages method contains a DO statement at the top and LOOP WHILE TRUE at the end of the routine. It then contains code to handle the UDP Packet.
I am considering placing this code in the global.asax of one of my web services.
Does anyone have any comments about possible pitfalls of this or suggestions as to other ways to get UDP packets to a web application ?
Apr 22, 2006 09:34 AM|madvisualbasic|LINK
Apr 23, 2006 02:47 AM|SteveNutt|LINK
I've experimented for hours but cannot get anything to work. I need an overview of how this should work....
1. What ports should the remote client send the packet on and can I receive on a different port ?
I have to send on port 80 so the packet can arrive at the web service, but cannot create a UDPClient on port 80 as an exception is thrown that the port is already in use.
2. The Init() method in Global.asax - should it create a new thread each time a packet arrives, or should it create a continous loop the first time it runs ?
Any suggestions apprciated.
Apr 24, 2006 06:00 AM|madvisualbasic|LINK
Jul 29, 2009 02:47 AM|m_ah85|LINK
hi steve did you make it worked?
i just did same thing and put the code in the init()
but i have to open the web page to start the aplication after that i get one packet but could not get the rest of it
Jul 29, 2009 09:39 AM|johnwsaunders3|LINK
Did you notice that you're replying to a post from more than three years ago?
Please start a new thread. They cost the same amount as replying to an old thread, but people will laugh at you less.
Apr 16, 2013 01:29 AM|markgroner|LINK
something wrong with replying to a post from more than three years ago?
Hope you learned manners since then.