• Post Reply Bookmark Topic Watch Topic
  • New Topic

UDP without IP  RSS feed

 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Henry Wong
author
Sheriff
Posts: 22861
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 22861
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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

 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!