473,516 Members | 3,488 Online
Bytes | Software Development & Data Engineering Community
+ 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 7217
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
2508
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, client is connecting without problems; but when servre is down and i start client, client connect to server! Few lines from code: client.Socket =...
15
4451
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 computations, the only data transfered is user mouse/kbd input. It works synchronously, but somehow, when I play in client window, both client and ...
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 clients. Also there's a commented code where i'm using TCPListener instead of simple Socket Class. The problem i'm having is that when I run this code...
2
6861
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 there is a problem with the connection. I need to know which client has sent the incoming data as each client has its own buffer on my "server"...
14
12719
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 whether to accept(read) the body. if server decided to throw(dump) the request's body, it'll send back a response message, such as "resource...
0
1716
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 createSocketServer($host='192.168.1.34',$port=2222) { $max_clients = 10;
2
4084
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 server machine IP for client and server) please guide me? server : #include <winsock2.h> #include <iostream> #include <stdio.h> #include...
6
4902
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
2203
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 les boucles. d'abord code serveur: from socket import * import socket, sys, threading class ThreadClient(threading.Thread):
0
7273
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7547
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5106
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3265
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.