This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Datagram sockets HELP NEEDED!  RSS feed

 
jambeard lewistrix
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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

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

Thanks

James
 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!