473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem on MSDN

Hi Guys

I have just taken this article from msdn and it is coming up with an error
any ideas why? If any one wants to see where I found it
http://msdn.microsoft.com/library/de...dpservices.asp

There error i get is 'Sub Main' is declared more than once in
'ConsoleApplication2': ConsoleApplication2.UDPMulticastListener.Main(),
ConsoleApplication2.UDPMulticastListener.Main(args () As String) As Integer
[Visual Basic]
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text

Public Class UDPMulticastListener

Private Shared GroupAddress As IPAddress = _
IPAddress.Parse("224.168.100.2")
Private Shared GroupPort As Integer = 11000

Private Shared Sub StartListener()
Dim done As Boolean = False

Dim listener As New UdpClient()
Dim groupEP As New IPEndPoint(GroupAddress, GroupPort)

Try
listener.JoinMulticastGroup(GroupAddress)
listener.Connect(groupEP)

While Not done
Console.WriteLine("Waiting for broadcast")
Dim bytes As Byte() = listener.Receive(groupEP)

Console.WriteLine("Received broadcast from {0} :" + _
ControlChars.Cr + " {1}" + ControlChars.Cr, _
groupEP.ToString(), _
Encoding.ASCII.GetString(bytes, 0, bytes.Length))
End While

listener.Close()

Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub 'StartListener

' Entry point that delegates to C-style main Private Function.
Public Overloads Shared Sub Main()
System.Environment.ExitCode = _
Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads Public Shared Function Main(args() As [String]) As Integer
StartListener()

Return 0
End Function 'Main
End Class 'UDPMulticastListener

Nov 21 '05 #1
2 1976
"Michael Turner" <fi*****@m-turner.co.uk> schrieb:
I have just taken this article from msdn and it is coming up with an error
any ideas why? If any one wants to see where I found it
http://msdn.microsoft.com/library/de...dpservices.asp

There error i get is 'Sub Main' is declared more than once in
'ConsoleApplication2': ConsoleApplication2.UDPMulticastListener.Main(),
ConsoleApplication2.UDPMulticastListener.Main(args () As String) As Integer
[Visual Basic]
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text

Public Class UDPMulticastListener

Private Shared GroupAddress As IPAddress = _
IPAddress.Parse("224.168.100.2")
Private Shared GroupPort As Integer = 11000

Private Shared Sub StartListener()
Dim done As Boolean = False

Dim listener As New UdpClient()
Dim groupEP As New IPEndPoint(GroupAddress, GroupPort)

Try
listener.JoinMulticastGroup(GroupAddress)
listener.Connect(groupEP)

While Not done
Console.WriteLine("Waiting for broadcast")
Dim bytes As Byte() = listener.Receive(groupEP)

Console.WriteLine("Received broadcast from {0} :" + _
ControlChars.Cr + " {1}" + ControlChars.Cr, _
groupEP.ToString(), _
Encoding.ASCII.GetString(bytes, 0, bytes.Length))
End While

listener.Close()

Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub 'StartListener
\\\
Public Shared Sub Main()
StartListener()
End Sub
///
End Class 'UDPMulticastListener


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Hi

Thanks, but I now get the following error

System.Net.Sockets.SocketException: An invalid argument was supplied
at System.Net.Sockets.Socket.setMulticastOption(Socke tOptionName
optionName,
MulticastOption MR)
at System.Net.Sockets.Socket.SetSocketOption(SocketOp tionLevel
optionLevel, S
ocketOptionName optionName, Object optionValue)
at System.Net.Sockets.UdpClient.JoinMulticastGroup(IP Address
multicastAddr)
at ConsoleApplication2.UDPMulticastListener.StartList ener() in
C:\Documents a
nd Settings\Michael\My Documents\Visual Studio
Projects\ConsoleApplication2\Modu
le1.vb:line 19

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
"Michael Turner" <fi*****@m-turner.co.uk> schrieb:
I have just taken this article from msdn and it is coming up with an
error any ideas why? If any one wants to see where I found it
http://msdn.microsoft.com/library/de...dpservices.asp

There error i get is 'Sub Main' is declared more than once in
'ConsoleApplication2': ConsoleApplication2.UDPMulticastListener.Main(),
ConsoleApplication2.UDPMulticastListener.Main(args () As String) As
Integer
[Visual Basic]
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text

Public Class UDPMulticastListener

Private Shared GroupAddress As IPAddress = _
IPAddress.Parse("224.168.100.2")
Private Shared GroupPort As Integer = 11000

Private Shared Sub StartListener()
Dim done As Boolean = False

Dim listener As New UdpClient()
Dim groupEP As New IPEndPoint(GroupAddress, GroupPort)

Try
listener.JoinMulticastGroup(GroupAddress)
listener.Connect(groupEP)

While Not done
Console.WriteLine("Waiting for broadcast")
Dim bytes As Byte() = listener.Receive(groupEP)

Console.WriteLine("Received broadcast from {0} :" + _
ControlChars.Cr + " {1}" + ControlChars.Cr, _
groupEP.ToString(), _
Encoding.ASCII.GetString(bytes, 0, bytes.Length))
End While

listener.Close()

Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub 'StartListener

\\\
Public Shared Sub Main()
StartListener()
End Sub
///
End Class 'UDPMulticastListener


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jimmy | last post by:
Hi folks, I'm hoping someone has a suggestion to solve this. I've been using Visual Studio Enterprise 6 (just the VB6 part) on my Dell laptop (PIII-700) running Win Me for a few years now, with...
3
by: Kenneth Lai | last post by:
After installed MSDN Library Oct 2003. I got a HTML error "Action Cancel" on the first page and no contents can be loaded. I try reinstall several time and still got this problem. Anyone...
4
by: Steve House | last post by:
I'm running VS.Net 2003 on an XP system with the most recent MSDN library integrated into it. When you do a search in the help, only "a"'s appear in the search results title column as a column 1...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
14
by: VMI | last post by:
Everytime I open my machine's MSDN and look for a subject, when I double-click on anything, I get "The page cannot be displayed" . What's wrong?
40
by: news.microsoft.com | last post by:
To Microsoft and fellow MSDN Universal subscribers... Regarding new MSDN Universal (I mean Premier) price and level changes: 1) Way too expensive for the small and medium developer Universal...
4
by: Al Norman | last post by:
We have two separate DLLs that do not interact (directly, at least). One is an MFC extension DLL that was built back in VC++ 6 days (but has been recompiled with VS2005). The other is a DLL that...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
6
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.