• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Datagram sockets HELP NEEDED!

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly if anyone knows any texts / sites which have a lot of info on datagrams could you please tell me!

Ok, I have an assignment which requires me to make a server that can handle multiple clients (and make the clients) using datagram sockets / packets.

One of the things it asks me to do is; when a client connects to the server, the server needs to record the clients name and IP address.

I have NO idea how to do this, I can send packets with datagrams and simple things like that but have no idea how to do this.

Could someone PLEASE help!!

If you want to take a look at the code I have so far go to

https://coderanch.com/t/377591/java/java/Network-assignment-HELP-NEEDED

Thanks

James
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you can receive packets you simply call the .getAddress() to get the IP address, and .getPort() to get the port.

For example,


Karen
[ August 16, 2005: Message edited by: Karen Baog ]
 
jambeard lewistrix
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any other info you can give me on datagrams?

I'm supposed to make a client and server program for travel agents. The client is supposed to be able to log on and off from the server (all using datagrams) but from what i uderstand you can't really do that with datagrams because they're a bit random.

I can send / recieve packets but REALLY don't understand how to do anything else with them. Also, after i've recieved a packet, how do I turn the data from a stream of bytes back into a string?
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic