• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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?
 
What are you doing? You are supposed to be reading this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic