473,491 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

UDP Client vs Socket

I'm in the process of creating a multicast application but I'm having
difficulty getting the UDPClient to work. The UDPClient works on my local
machine only, not across the network. I've been able to get the multicast
message to work across a network by creating a socket, but I can't get it to
work via UDPClient. What is the difference between the two? Why does the
socket method work and not the UDPClient? Thanks

*****************SOCKET METHOD*********************

Socket s=new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);

s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new
MulticastOption(ip));

s.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, int.Parse(ttl));

IPEndPoint ipep=new IPEndPoint(IPAddress.Parse(mcastGroup),int.Parse(p ort));

s.Connect(ipep);

*********************UDPCLIENT METHOD***********************

udpClient = new UdpClient();
groupEP = new IPEndPoint(groupAddress, groupPort);
int sendBytes = udpClient.Send(data, data.Length, groupEP);
Nov 17 '05 #1
2 7201
I believe you need to make a call to JoinMulticastGroup on the UdpClient
class. This method allows you to supply the multicast address and the TTL.

HTH
Dan

"chewie" wrote:
I'm in the process of creating a multicast application but I'm having
difficulty getting the UDPClient to work. The UDPClient works on my local
machine only, not across the network. I've been able to get the multicast
message to work across a network by creating a socket, but I can't get it to
work via UDPClient. What is the difference between the two? Why does the
socket method work and not the UDPClient? Thanks

*****************SOCKET METHOD*********************

Socket s=new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);

s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new
MulticastOption(ip));

s.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, int.Parse(ttl));

IPEndPoint ipep=new IPEndPoint(IPAddress.Parse(mcastGroup),int.Parse(p ort));

s.Connect(ipep);

*********************UDPCLIENT METHOD***********************

udpClient = new UdpClient();
groupEP = new IPEndPoint(groupAddress, groupPort);
int sendBytes = udpClient.Send(data, data.Length, groupEP);

Nov 17 '05 #2
I believe you need to make a call to JoinMulticastGroup on the UdpClient
class. This method allows you to supply the multicast address and the TTL.

HTH
Dan

"chewie" wrote:
I'm in the process of creating a multicast application but I'm having
difficulty getting the UDPClient to work. The UDPClient works on my local
machine only, not across the network. I've been able to get the multicast
message to work across a network by creating a socket, but I can't get it to
work via UDPClient. What is the difference between the two? Why does the
socket method work and not the UDPClient? Thanks

*****************SOCKET METHOD*********************

Socket s=new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);

s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new
MulticastOption(ip));

s.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, int.Parse(ttl));

IPEndPoint ipep=new IPEndPoint(IPAddress.Parse(mcastGroup),int.Parse(p ort));

s.Connect(ipep);

*********************UDPCLIENT METHOD***********************

udpClient = new UdpClient();
groupEP = new IPEndPoint(groupAddress, groupPort);
int sendBytes = udpClient.Send(data, data.Length, groupEP);

Nov 17 '05 #3

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

Similar topics

2
2505
by: news.microsoft.com | last post by:
Hi I write dll library which one of it component will be Net socket communication. Communication is working very good, but i've got problem when client is connecting. When server is started,...
15
4446
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do...
0
1450
by: Usman | last post by:
Hi I'm having problem with a scenarion where I have a server written in C# and client written in VC6++. Here is the server code that i'm using including the Callback function for handling...
2
6857
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
14
12708
by: ahlongxp | last post by:
Hi, everyone, I'm implementing a simple client/server protocol. Now I've got a situation: client will send server command,header paires and optionally body. server checks headers and decides...
0
1711
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function...
2
4082
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set...
6
4900
by: 7stud | last post by:
My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv textport = sys.argv s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
1
2199
by: tsic | last post by:
Bonjour, je suis bloqué ilya preque 2 semaines dans le code suivant. je veut que le client et le serveur envoyent leurs message d'une maniere comme msn. je crois qu'ilya quelque chose à ajouter dans...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.