• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UDP without IP

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,

I am new to socket programming. I want to develop a chat application. In this case I want to send messages to all nodes on the LAN. Can I do this using UDP sockets? But I don't know other node's IP addresser's. please help me.

Thank you.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chat generally works through a chat server that mediates between all clients, not directly between two clients. So you only need the IP address of the server (which should be fixed and well-known).
 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank for reply. I can do it using server.I knew it. But I want to do it individually. I mean no server. One node has a server class as well as client class. In this case first of all I want to send my IP and my unique port number to other nodes. After that they will reply me If they connected. The problem is how can i send my informations to others without using any IP address? Please help me.

Thank you.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using UDP broadcast messages could make this possible (since you only want it on the LAN, which I assume has only one subnet), but UDP isn't a good protocol for chat applications. It's unreliable; messages may not arrive, or arrive in an incorrect order.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Using UDP broadcast messages could make this possible (since you only want it on the LAN, which I assume has only one subnet), but UDP isn't a good protocol for chat applications. It's unreliable; messages may not arrive, or arrive in an incorrect order.



Using Multicast is better than Broadcast here. With Multicast, the switch (IGMP supported) should only send to interested computers on the LAN. On top of that, it is possible to multicast all of the world if you want (assuming the routes are configured of course).

Henry
 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank you all for replying. Rob Spoor, you are correct. Actually I want to implement this application on a LAN. but I still trying to do this work with your method as well as Henry Wong's method. but in both cases I have to give a particular IP address. I want to send my informations to others using a particular Port number. I herd about broadcast IP in LAN's. Using this IP address we can send signal's to all nodes on the LAN. I think using this concept I can do my work. Please help me.

Thank you.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

dushantha Rathnayake wrote:... I still trying to do this work with your method as well as Henry Wong's method. but in both cases I have to give a particular IP address.



Just being a bit anal here, terminology wise, neither of these are IP addresses. For broadcast, it is a broadcast address. For multicast, it is a multicast group address. Neither of these addresses are IP address, as they don't go to a particular machine. Broadcast messages go to all machines. Multicast messages goes to all machines who are receiving on that address.

Regardless of using unicast, multicast, or broadcast, you are required to provide an address and port. With multicast, you don't have to provide an IP address, but you have to specify an address nonetheless.

Henry

 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:
Just being a bit anal here, terminology wise, neither of these are IP addresses. For broadcast, it is a broadcast address. For multicast, it is a multicast group address. Neither of these addresses are IP address, as they don't go to a particular machine. Broadcast messages go to all machines. Multicast messages goes to all machines who are receiving on that address.


Well, if we're being really picky, the broadcast absolutely is an IP address. It's not a station address. The first and last IPs in a subnet are served for network identification and all-station addressing, respectively.

To the properly perverse individual, there are some interesting uses for the broadcast address. For example, if you ping it, everyone on the subnet accepting ping requests responds. Fast, easy way to fill an ARP cache.
 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

dushantha Rathnayake wrote:Hi,

I want to send my informations to others using a particular Port number. I herd about broadcast IP in LAN's. Using this IP address we can send signal's to all nodes on the LAN. I think using this concept I can do my work. Please help me.

Thank you.



What makes a socket unique is that it is made up of both an IP address and a port number, if you are planning on sending data to another computer you need an IP address.

Hunter
 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank you all for everything. Finally I found an answer. I put the Broadcast IP onto address parameter in InetSocketAddress. So it's work now.



Thank you.
reply
    Bookmark Topic Watch Topic
  • New Topic