473,756 Members | 3,111 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(AddressF amily.InterNetw ork, SocketType.Dgra m,
ProtocolType.Ud p);

s.SetSocketOpti on(SocketOption Level.IP, SocketOptionNam e.AddMembership , new
MulticastOption (ip));

s.SetSocketOpti on(SocketOption Level.IP,
SocketOptionNam e.MulticastTime ToLive, int.Parse(ttl)) ;

IPEndPoint ipep=new IPEndPoint(IPAd dress.Parse(mca stGroup),int.Pa rse(port));

s.Connect(ipep) ;

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

udpClient = new UdpClient();
groupEP = new IPEndPoint(grou pAddress, groupPort);
int sendBytes = udpClient.Send( data, data.Length, groupEP);
Nov 17 '05 #1
2 7300
I believe you need to make a call to JoinMulticastGr oup 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(AddressF amily.InterNetw ork, SocketType.Dgra m,
ProtocolType.Ud p);

s.SetSocketOpti on(SocketOption Level.IP, SocketOptionNam e.AddMembership , new
MulticastOption (ip));

s.SetSocketOpti on(SocketOption Level.IP,
SocketOptionNam e.MulticastTime ToLive, int.Parse(ttl)) ;

IPEndPoint ipep=new IPEndPoint(IPAd dress.Parse(mca stGroup),int.Pa rse(port));

s.Connect(ipep) ;

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

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

Nov 17 '05 #2
I believe you need to make a call to JoinMulticastGr oup 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(AddressF amily.InterNetw ork, SocketType.Dgra m,
ProtocolType.Ud p);

s.SetSocketOpti on(SocketOption Level.IP, SocketOptionNam e.AddMembership , new
MulticastOption (ip));

s.SetSocketOpti on(SocketOption Level.IP,
SocketOptionNam e.MulticastTime ToLive, int.Parse(ttl)) ;

IPEndPoint ipep=new IPEndPoint(IPAd dress.Parse(mca stGroup),int.Pa rse(port));

s.Connect(ipep) ;

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

udpClient = new UdpClient();
groupEP = new IPEndPoint(grou pAddress, 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
2522
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 = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
15
4490
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 server have 17 fps, while when playing in server window, server has 44 fps while client ...
0
1462
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 using Socket class, the server starts well but "OnClientConnect" method never gets called. On...
2
6877
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" app. I am using the standard asynch socket code from MSDN to listen for connections and they...
14
12794
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 already exists" and close the connection.
0
1746
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
4101
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 <string.h> #include <windows.h> #pragma comment(lib, "ws2_32");
6
4923
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
2210
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
9152
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9716
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9716
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8569
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7116
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3676
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 we have to send another system
2
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2542
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.